From 7d3e3c509d20addb32ab6701155b35a7023d3b4d Mon Sep 17 00:00:00 2001 From: lookshe Date: Tue, 20 Sep 2011 23:16:53 +0200 Subject: changed to get date if it is required (last speaking time was not today) --- lastspoke.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lastspoke.pl') 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 { -- cgit v1.2.3