Next | Perl Regex Engine | 6 |
$number = "(?:\d+|\d*\.\d+(?:[eE]\d+)?)"; while (<>) { print if /$number\s+$number (Kelvins|Meters).*$number/; }
Here the regex contains variables
At run time these are interpolated and the result is compiled
For each match
We can speed this up by promising Perl that that variables will never change:
print if /.../o;
On the first match, Perl compiles the pattern
Never compiles it again
Next | Copyright © 2001 M. J. Dominus |