++ on the bad variable names. The fact that the variables have numbers is a first sign that the names are probably not well chosen, but having two variables with the same names (a hash and a scalar named file2) should absolutely be avoided.
Your proposition works fine if the lines in $data are unique, (the fact that they are counted using $file2{$line}++ makes me think they may not be) but will print duplicates otherwise.
In reply to Re^2: searching string from one file in another
by Eily
in thread searching string from one file in another
by freakpea
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |