develooper Front page | perl.perl5.porters | Postings from March 2013

Is this a /^*/ bug?

Thread Next
From:
Tom Christiansen
Date:
March 25, 2013 15:55
Subject:
Is this a /^*/ bug?
Message ID:
29749.1364226923@chthon
I realize this is nonsense, but I wonder if it is not a bug.  Shouldn't the
overall pattern still fail, not succeed?

    % perl -WE 'say "foo.bar" =~ /^.*.bar$/ || "FAIL"'
    1

    % perl -WE 'say "foo.bar" =~ /^*.bar$/ || "FAIL"'
    ^* matches null string many times in regex; marked by <-- HERE in m/^* <-- HERE .bar$/ at -e line 1.
    1

    % perl -WE 'say "foo.bar" =~ /(^*).bar$/ || "FAIL"'
    ^* matches null string many times in regex; marked by <-- HERE in m/(^* <-- HERE ).bar$/ at -e line 1.
    1

    % perl -WE 'say "foo.bar" =~ /^.bar$/ || "FAIL"'
    FAIL

Tested with v5.8.8, v5.14.0, v5.16.0, and v5.17.0-352-g3630f57.

--tom

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About