How does the qr/STRING/ operator in Perl decide whether or not to compile STRING?
perl, regex
Solution
The "possibly compiles" part of the documentation probably refers to situations like the one shown below, where the argument to `qr//` is an already-compiled regex:
use re 'debug';
$re1 = qr/foo/;
$re2 = qr/$re1/;
Running that program shows only one regex being compiled.
Regardless of the intent of that passage, sly allusions to internals details does not clear documentation make. I think a doc patch would be beneficial.
Problem
The docs for `qr/STRING/` say: This operator quotes (and possibly compiles) its `STRING` as a regular expression. What worries me is the part in parentheses. I can't think of any cases where I don't want it to compile a regex out of `STRING`. Is this parenthetical statement just weasel words to cover some future case where compiling is not desired or is there a case today (or in an earlier version of Perl) where `STRING` will not be compiled?