in reply to Searching and printing through a array

rsriram,

Change @all[$x] which is an array slice into $all[$x]which is a individual element in an array. The below is equivalent to your code.

for my $x (0..$#all) { if($line =~ /$all[$x]/) { print F2 $line; } } simply: foreach (@all) { print F2 $line if $line =~ /$_/; }
If you show the input and output, it is easy to help you out.
Also you can do the same using grep and quotemeta.

Prasad