hi all,
I need to match any array element in a list of files. More precisely
I'd to extract the $. for each match recording an hash element like
this one:
$matches{$filename} = $.
Every file is a list of unique words, so I'm sure there will not be
problems.
My actual solution sounds like:
foreach $file (@listoffiles)
{
open (IDX, "<$file") or die "error on $file: $!\n";
while(<IDX>)
{
foreach $word (@listofwords)
{
$match{$file}= $. if /^$word$/;
}
print "done $file\n" if eof;
}
close(IDX);
}
Two questions:
1) is there a way to avoid a foreach in a foreach?
2) the (possible) other solution is faster than a foreach in a foreach
or it's only a different way to write it?
thanx at all
alladr
|^|_|^|_|^| |^|_|^|_|^|
| | | |
| | | |
| |*\_/*\_/*\_/*\_/*\_/* | |
| |
| |
| |
| http://www.e-allora.net |
| |
| |
**************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>