Re: looping through a file On 5/7/07, Robert Hicks  wrote: > I have one file that contains a log. I do a substr to get the > information out of that and push it into an array. > > I have a second file that contain another log. I need to loop through > the items in the array and find them in this log. Once I find the line > that the id is on, I need the next line /^AMP-commit/ captured. > > I am getting: > > "Use of uninitialized value in pattern match (m//) at ./amp_parse.pl > line 39, <$AFILE> line 213622." snip It sounds like your substr is returning undef at some point in the first file.  If this is not an error then try changing the loop to while (defined(my $ifile_line = <$IFILE>)) {     my $hits = substr($ifile_line, 0, 6);     next unless defined $hits;     push @id_hits, $hits; } Also, you should never use a straight string in a regex; it should aways be quoted. $line = shift @log until $line =~ /\\Q$prime_id\\E/; --  To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org http://learn.perl.org/