From ba46c304bdffdce0b6019a47f6759ce6abbeef90 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Tue, 16 Aug 2011 10:51:41 +0200 Subject: Initial commit --- firstseen.pl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 firstseen.pl (limited to 'firstseen.pl') diff --git a/firstseen.pl b/firstseen.pl new file mode 100644 index 0000000..9eceff8 --- /dev/null +++ b/firstseen.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl + + +if ($#ARGV ne 2){ + print "not enough arguments\n"; + exit 1; +} + +my $chan=$ARGV[1]; +my $folder=$ARGV[0]; +my $nick=$ARGV[2]; + +my @files; + +push @files, `ls $folder/$chan.* | sort`; + +foreach $file (@files) { + +my $date="irgendwas"; +my $line; + +open(file, $file) or die("Could not open file $file"); +foreach $line () { + if ($line =~ m/^\[[0-9]{2}:[0-9]{2}(:[0-]{2})?\] (Action: )?? /i) { + if ($date =~ /^irgendwas$/) { + print "$nick belongs to inventory\n"; + exit 0; + } else { + ($time=$line)=~s/(.*)([0-9]{2}:[0-9]{2}(:[0-9]{2})?)(.*)\n/$3/; + print "$nick was first seen on $date at $time\n"; + exit 0; + } + } + if ($line =~ m/^\[00:00(:00)?\] --- /){ + ($date=$line)=~s/^\[00:00(:00)?\] --- (.*)\n/$2/; + } +} +} + +print "I do not remember $nick\n"; -- cgit v1.2.3