| Next | Regular Expression Mastery | 62 |
my $pat = shift;
while (<>) {
print if /$pat/;
}
Here the pattern does not vary at runtime
Perl still checks each time to see if it has changed
my $pat = shift;
while (<>) {
print if /$pat/o;
}
/o modifier promises that the pattern will never change
Perl no longer needs to check
| Next | ![]() |
Copyright © 2002 M. J. Dominus |