mdotpl has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, Here's where I'm at: Parsing auth log for a sessionID which will be used to extract particular request lines with the sessionID in message log. I'm having trouble with the foreach within a foreach loop. I can't figure out how to do this effectively. As I continue to tackle this, any advice / wisdom would be greatly appreciated! :)
open(AUTH) or die("couldn't open auth"); foreach $line (<AUTH>) { chomp($line); if($line =~ m/<my-regex-goes-here>/i) { push(@sessionID, $4); } } close(AUTH); open(MSG) or die("couldn't open msg log"); foreach $line (<MSG>) { chomp($line); push(@array, $line); } close(MSG); foreach $line (@array) { foreach $id (@sessionID) { # Look for auth request with sessionID if($line =~ m/<my-regex-goes-here($id)>/i) { push(@list, $line); } } } foreach $lines (@list) { print $lines; print "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parsing Logs
by moritz (Cardinal) on Oct 05, 2012 at 16:59 UTC | |
Re: Parsing Logs
by mbethke (Hermit) on Oct 05, 2012 at 17:03 UTC | |
Re: Parsing Logs
by johngg (Canon) on Oct 05, 2012 at 18:14 UTC | |
Re: Parsing Logs
by toolic (Bishop) on Oct 05, 2012 at 16:39 UTC | |
Re: Parsing Logs
by mdotpl (Initiate) on Oct 05, 2012 at 18:34 UTC | |
Re: Parsing Logs
by grizzley (Chaplain) on Oct 08, 2012 at 08:52 UTC |
Back to
Seekers of Perl Wisdom