KLassesen has asked for the wisdom of the Perl Monks concerning the following question:
I'm tracking down a performance problem (likely some bad regexp) and have a file of existing regexps that is used to filter content. I have been away from Perl for too long a time...
So I want to read the file line by line and convert each to a regexp that I will apply against a reference text (32K) and record the time. The key is to identify the worst ones to look for rewriting. My logic to date is:
while (<FILE>) {
chomp{$_);
if(length $_ > 1)
{
$regex =~ $_;
$_=$sampletext;
if(/$regex/)
{
}
}}
I'm getting uninitialized values in pattern match and suspect that I have a minor error somewhere -- but can't spot it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading and executing RegExp from text file
by JavaFan (Canon) on Oct 28, 2011 at 01:00 UTC | |
|
Re: Reading and executing RegExp from text file
by ww (Archbishop) on Oct 28, 2011 at 12:25 UTC |