in reply to A regular expression (or regex)
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 }
|
|---|