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"; }
In reply to Parsing Logs by mdotpl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |