in reply to Re: "Use of uninitialized value in print" but why ???
in thread "Use of uninitialized value in print" but why ???

I agree to a point, but you want to iterate all of the matches for each line. Wouldn't you need a way to restart the <$match_in> iterator in your example? I think the code would be better written:

... my @matches = <$match_in>; ... while (my $lines = <$fh_in>) { for my $matches ( @matches ) { ...

I wasn't really sure if I was right or not, so I whipped up a script quick.

#!/usr/bin/perl use strict; open my $fh1, '<', 'file_iterator1'; open my $fh2, '<', 'file_iterator2'; while ( my $line1 = <$fh1> ) { chomp $line1; while ( my $line2 = <$fh2> ) { chomp $line2; print "$line1:\t$line2\n"; } }

file_iterator1:

one two three

file_iterator2:

ay bee see

Output:

one: ay one: bee one: see

Notice that the second file iterator doesn't run through again for the 'two' and 'three' lines.

    -Bryan