in reply to Re: Set::Scalar - Regexp as method parameter?
in thread Set::Scalar - Regexp as method parameter?

//'s not necessary if $regex was built with qr.

Actually, if you leave out the slashes, the regex is put in string context, and the speed gain is lost.

$foo =~ '^string literal$'; # Does not equal /\Q^string literal$/ $foo =~ $string; $foo =~ subroutine(); $foo =~ bareword; # Unless $INC{'strict.pm'} $foo =~ $precompiled_regex; # Is stringified first! $foo =~ /$precompiled_regex/; # Faster
I've even seen people do bizarre things because they think qr//s are faster without slashes:
# Bad: (well, it works, but not the way you want it to) $foo =~ $qr; $foo =~ s//bar/; # Good: $foo =~ s/$qr/bar/;

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.