in reply to Find partially matching line in file - print that line to another file

Hi,

my code it's a bit different, but it's working ... what is the problem?

use strict; my @fileone = qw/ 123456 123457 123458/; while (my $line = <DATA>) { foreach my $pattern(@fileone) { if ($line =~ /^$pattern/) {print $line."\n";} } } __DATA__ 123456 foo 123456 bar 123457 foobar 123455 this wouldn't be printed to new file
output
123456 foo 123456 bar 123457 foobar

Replies are listed 'Best First'.
Re^2: Find partially matching line in file - print that line to another file
by rkmase (Novice) on Dec 14, 2007 at 15:10 UTC
    This is exactly what I was looking for. I imagine it was the different order that I tried to process mine that did it.

    Thanks! Mason