S
Sandman
I am doing some logfile parsing (of an online chat function) and have a
script in particular that sums events that are being searched for. In
short:
Logfile structure:
JOIN 12:34 Lucille!12.34.43.21 joined
KICK 12:35 Smith!23.45.170.23 kicked Lucille
JOIN 12:36 Lucilla!12.34.43.21 joined
KICK 12:37 Smith!23.45.170.23 kicked Lucilla
(note the difference in name of Lucilla/Lucille)
So, when summing up the presence of a particular user, I grep the file
and deal with the result in a foreach:
forach (@lines){
chomp;
($kind,$time,$host,@text)=split " ";
$thetext = join " ", @text;
($nick,$ip)=split "!", $host;
push @nicks, $nick;
$sum{$ip}{$kind}++;
}
That's a short version. Now, the @lines array contains information I've
grep:ed for, and as such, Lucille can be found with different nicks,
which I save in @nicks (well, I save all of them, not only the differing
ones).
So, in my summary, I want summarize how many times Lucille has been
kicked. Now, the key is the IP, not the nick, and the IP of the kickee
isn't present in the kick line, which is why I save the nicks. What I am
looking for is something like this, in pesudo:
if $thetext contains "kicked (any of the nicks in @nicks)"
How would you do it?
script in particular that sums events that are being searched for. In
short:
Logfile structure:
JOIN 12:34 Lucille!12.34.43.21 joined
KICK 12:35 Smith!23.45.170.23 kicked Lucille
JOIN 12:36 Lucilla!12.34.43.21 joined
KICK 12:37 Smith!23.45.170.23 kicked Lucilla
(note the difference in name of Lucilla/Lucille)
So, when summing up the presence of a particular user, I grep the file
and deal with the result in a foreach:
forach (@lines){
chomp;
($kind,$time,$host,@text)=split " ";
$thetext = join " ", @text;
($nick,$ip)=split "!", $host;
push @nicks, $nick;
$sum{$ip}{$kind}++;
}
That's a short version. Now, the @lines array contains information I've
grep:ed for, and as such, Lucille can be found with different nicks,
which I save in @nicks (well, I save all of them, not only the differing
ones).
So, in my summary, I want summarize how many times Lucille has been
kicked. Now, the key is the IP, not the nick, and the IP of the kickee
isn't present in the kick line, which is why I save the nicks. What I am
looking for is something like this, in pesudo:
if $thetext contains "kicked (any of the nicks in @nicks)"
How would you do it?