Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;
use Time::Piece;
my $OUTFILE = "/root/count.csv";
my $infile = shift;
my %csv;
{
open (my $in,"<", $infile) or die $!;
while(<$in>){
if ($_ =~ m#\[\d+/Apr/2021:\d\d#){
my $t = Time::Piece->strptime("$&:00". " +0000", '[%d/%b/%Y:%H:%M %z');
my $date = $t->strftime("%Y/%m/%d %H:%M:%S");
$csv{$date}++;
}
}
}
for (sort keys %csv){
say "$_\t$csv{$_}";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment