in reply to Perl bug or feature?

...but it set to '', then it uses the first compiled regex instead
If the PATTERN evaluates to the empty string, the last successfully matched regular expression is used instead.

Replies are listed 'Best First'.
Re^2: Perl bug or feature?
by bart (Canon) on Oct 26, 2010 at 11:24 UTC
    Even though I knew about — and respect — perl's behaviour to repeat the match with an empty regex //, I do feel that this should not apply to the case where the empty regex is a result of interpolating an empty variable: $re = ''; /$re/

    Usually, the variable's data comes from user input, and that should not fall back to a shortcut which is intended for intra-source only.