in reply to Searching and printing through a array

Can we see some sample input (both what is in $line and what is in @all). Your method isn't very Perlish, but it should work.

If you had "use warnings" in your code then you would be warned about using @all[$x] where you almost certainly mean $all[$x]. Also, you're probably better off using a "foreach" loop instead of the C-style loop you have here.

foreach (@all){ if ($line =~ /$_/) { print F2 $line; } }

If you're comparing with a lot of lines then you might find it faster to create a regex from all of the elements of @all.

my $re = join '|', @all; $re = qr/$re/; if ($line =~ /$re/) { print F2 $line; }

Update: Corion's method of creating a regex is more robust than mine.