in reply to Reset meaning of empty pattern?

Try

'' =~ /()/;

Replies are listed 'Best First'.
Re^2: Reset meaning of empty pattern?
by LanX (Saint) on Sep 01, 2018 at 15:48 UTC
    Can't test now, but probably this one has side effects by setting $1.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      That's why I posted the other ones.

      On the other hand, does it really matter? If the user does not expect $1 to be set by //, whether it has a value or is undef is irrelevant.

        On the other hand, does it really matter?

        It does to me, since I inspect the results of the regex, including @+ to see how many capture groups there were.

        $ perl -wMstrict -le '""=~// or die; print for @+' 0 $ perl -wMstrict -le '""=~/(?:)/ or die; ""=~// or die; print for @+' 0 $ perl -wMstrict -le '""=~/()/ or die; ""=~// or die; print for @+' 0 0

        Updated examples.