M
Mothra
Am trying to match n occurences of a phrase ("Lost connection") in a text
file.
Here's the code I;ve got so far (I'm reading the whole file into the scalar
$lines)...
if ($lines =~ /(.*Lost connection.*(\n.*)*{4}/) {
print "yep\n";
} else {
print "nope\n";
}
The above works and prints "yep" if 4 or more occurences are found; however,
it's quite slow and if I want to match more occurences (e.g. 9) it takes
forever: almost as if the length of time the script takes to run is being
raised to the power of the number of occurences I'm trying to match!
How could I rewrite this regex more efficiently?
file.
Here's the code I;ve got so far (I'm reading the whole file into the scalar
$lines)...
if ($lines =~ /(.*Lost connection.*(\n.*)*{4}/) {
print "yep\n";
} else {
print "nope\n";
}
The above works and prints "yep" if 4 or more occurences are found; however,
it's quite slow and if I want to match more occurences (e.g. 9) it takes
forever: almost as if the length of time the script takes to run is being
raised to the power of the number of occurences I'm trying to match!
How could I rewrite this regex more efficiently?