http://www.perlmonks.org?node_id=1004930


in reply to Regular expression help

Anannassa, I think you are expending too much energy on splitting up the lines to match the separate parts

Though to clear the id you could use split. I have suggested a substition to strip the id out of the line. You then just compare the whole of the remaining line against the 2nd file lines.

This is untested but, should do the trick, if not give you another way to approach the problem.

#strip the id, repeating for each @sample array as necessary foreach (@sample){ s/^ID\d+\s+(.*)/$1/; } #set an array to catch the mathcing lines my @matches #now compare each array element in @sample1 to each array element in @ +sample2 my ($line1, $line2); foreach $line1 (@sample1){ foreach $line2 (@sample2){ push(@matches, $line2) if ($line2 eq $line1); } } print join("\n", @matches);

this type of thing can also be done using greps,maps and hash key indexing.