Code below has the two files read into arrays - while *I* think this should work, perl thinks differently. Can someone show me what I did wrong?
File one has:
123456
123457
123458
File two has:
123456 foo
123456 bar
123457 foobar
123455 this wouldn't be printed to new file
open(RESULT, "> result.txt") or die ("Unable to open file");
foreach $pattern(@fileone) {
foreach $line(@filetwo) {
if ($line =~ /^$pattern/) {print RESULT $line."\n";}
}
}