in reply to loops & sql results storage
For starters, the order of your loop and your conditional are backwards. There's no reason to check for a match for each element of @array.
foreach my $elem (@array){ $searchTitle=$array[0]; if ($searchTitle=~/(?=.*pr\w{4}m)(?=(?=\w*w\w*)(?=\w*b\w*)\w+\b)/){ print "<td>"; print "$elem\n"; print "<td>"; } }
should be
my $searchTitle = $array[0]; if ($searchTitle =~ /(?=.*pr\w{4}m)(?=(?=\w*w\w*)(?=\w*b\w*)\w+\b)/){ foreach my $elem (@array){ print "<td>"; print "$elem\n"; print "<td>"; } }
Beyond that, I'm not sure I can help you, since I don't understand what you are trying to do. What is the subroutine supposed to do? Writing the results to a file is does not appropriate.
|
|---|