If $pattern won't be changing over the lifetime of the script, we can +add the "//o" modifier, which directs Perl to only perform variable substitutions once: #!/usr/bin/perl # Improved simple_grep $regexp = shift; while (<>) { print if /$regexp/o; # a good deal faster }
In reply to Re: A regular expression (or regex)
by suhailck
in thread A regular expression (or regex)
by anakin30
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |