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


in reply to Match a list of numbers from a list of files

One thing that jumps out at me is that you are essentially traversing the file twice. You could check $line for a match at the same time you are push-ing it to @temp instead of creating @temp then checking each @temp. If you have a match, set a flag that tells you that something else needs to be done with @temp when you reach END.