diff options
author | lookshe <mail@lookshe.org> | 2011-09-20 23:16:53 +0200 |
---|---|---|
committer | lookshe <mail@lookshe.org> | 2011-09-20 23:16:53 +0200 |
commit | 7d3e3c509d20addb32ab6701155b35a7023d3b4d (patch) | |
tree | a5de439b21c973766af5aed1ac812cb560ec4b35 /lastspoke.pl | |
parent | c4b1a82f6b3ece544da0b6f42825b549aa6ac6f2 (diff) |
changed to get date if it is required (last speaking time was not today)
Diffstat (limited to 'lastspoke.pl')
-rw-r--r-- | lastspoke.pl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lastspoke.pl b/lastspoke.pl index 9ccf5d9..0661744 100644 --- a/lastspoke.pl +++ b/lastspoke.pl @@ -2,7 +2,7 @@ use File::ReadBackwards; -if ($#ARGV ne 3){ +if ($#ARGV ne 2){ print "not enough arguments\n"; exit 1; } @@ -10,7 +10,6 @@ if ($#ARGV ne 3){ my $folder=$ARGV[0]; my $chan=$ARGV[1]; my $nick=$ARGV[2]; -my $printdate=$ARGV[3]; my @files; @@ -22,6 +21,7 @@ foreach $file (@files) { my $date=0; my $lastaction; my $line; +my $datecount=0; $file=~s/\n$//; my $log = File::ReadBackwards->new($file) || die $!; @@ -32,9 +32,11 @@ while ($line=$log->readline()){ if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-9]{2})?\] <$nick> /i && $line !~ m/joined #/ ) { $date=1; ($lastaction=$line)=~s/\n//; + } elsif ($line =~ m/^\[00:00(:00)?\] --- /) { + ++$datecount } } else { - if ($printdate eq 0){ + if ($datecount eq 0){ print "$nick\'s last action: $lastaction\n"; exit 0; } else { |