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

You better print something, like print OUTFILE $lines;. Moreover, it's not optimal to read into memory the whole contents of files. Give this a try:

## Untested open my $match_in, '<', $match_file or die "1st open failed: $!"; open my $fh_in, '<', $in_file or die "2nd open failed: $!"; open my $fh_out, '>>', $out_file or die "3rd open failed: $!"; while (my $lines = <$fh_in>) { while (my $matches = <$match_in>) { chomp $matches; my $matchtmp = qr/$matches.*(?:SUPSOSODEV|AJTSOSO(?:CFD|ISI|CLA))/ +; ## Assuming you want to print $lines print $fh_out $lines if $lines =~ m/$matchtmp/; } } close $fh_out; close $fh_in; close $match_in;

--
David Serrano

Replies are listed 'Best First'.
Re^2: "Use of uninitialized value in print" but why ???
by mrborisguy (Hermit) on Dec 11, 2005 at 00:33 UTC

    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 ) { ...

        -Bryan