da@stanley.cis.brown.edu (Reindeer) (06/27/91)
This may be an FAQ, but:
Is there an fgrep() for perl? I really like being able to read in a
large file in an array (memory is no problem), but doing a grep() on
it is really slow, considering I'm looking for pretty boring strings
in it. Does anyone have a way to speedup the code below?:
(pseudo-perl)
@biggie = <BIG_FILE>;
while (!eof(OTHER_BIG_FILE))
{
$line = <OTHER_BIG_FILE>;
@words = split(' ', $line);
$keyword = @words[0];
$result = grep(/$keyword/, @biggie);
...
}
most of the time is spent in the grep line, which is not too
surprising but a bit frustrating. both files are several thousand
lines long.
Also: Is there a way to profile perl programs?
Thanks,
David Ascher, Perl novice.