<?xml version="1.0" encoding="windows-1252"?>
<node id="997512" title="Parsing Logs" created="2012-10-05 12:30:21" updated="2012-10-05 12:30:21">
<type id="115">
perlquestion</type>
<author id="997510">
mdotpl</author>
<data>
<field name="doctext">
&lt;p&gt;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! :)
&lt;/p&gt;

&lt;code&gt;
open(AUTH) or die("couldn't open auth");
foreach $line (&lt;AUTH&gt;) {
   chomp($line);
   if($line =~ m/&lt;my-regex-goes-here&gt;/i) {
      push(@sessionID, $4);
   }
}
close(AUTH);

open(MSG) or die("couldn't open msg log");
foreach $line (&lt;MSG&gt;) {
   chomp($line);
   push(@array, $line);
}
close(MSG);

foreach $line (@array) {
   foreach $id (@sessionID) {
      # Look for auth request with sessionID
      if($line =~ m/&lt;my-regex-goes-here($id)&gt;/i) {
         push(@list, $line);
      }
   }
}

foreach $lines (@list) {
   print $lines;
   print "\n";
}
&lt;/code&gt;</field>
</data>
</node>
