Skip Menu |

This queue is for tickets about the match-simple CPAN distribution.

Report information
The Basics
Id: 97507
Status: resolved
Priority: 0/
Queue: match-simple

People
Owner: Nobody in particular
Requestors: felix.ostmann [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.009
Fixed in: (no value)



Subject: match('', undef) == 0 VS match(undef, '') == 1
I was confused by the following behavior: $ perl -Mmatch::simple=match -e 'print match(undef,"") ? "yes" : "no","\n";' yes $ perl -Mmatch::simple=match -e 'print match("",undef) ? "yes" : "no","\n";' no I am not sure if this was intended, but i can't find something in the documentation that the order of the arguments is important. Have a nice day Felix
The documentation states: "Unlike smart match, the behaviour of the match is determined entirely by the operand on the right hand side." And also: "If the right hand side is undef, then there is only a match if the left hand side is also undef." Which means that match("", undef) will be false, because the left hand side isn't undef. And also: "If the right hand side is a non-reference, then the match is a simple string match." Which means that match(undef, "") will be true, because the left hand side is equal to "" under string equality rules.
From: felix.ostmann [...] gmail.com
OK, but i don't like this behavior in this special case and the documentation is not clear, that the order of the arguments is important for the result. Perhaps at least a new hint would be great: Beware of the order of the arguments (especial when including undef). The result can be different, when the order change. Am Sa 26. Jul 2014, 17:21:11, TOBYINK schrieb: Show quoted text
> The documentation states: > > "Unlike smart match, the behaviour of the match is determined entirely > by the operand on the right hand side." > > And also: > > "If the right hand side is undef, then there is only a match if the > left hand side is also undef." > > Which means that match("", undef) will be false, because the left hand > side isn't undef. > > And also: > > "If the right hand side is a non-reference, then the match is a simple > string match." > > Which means that match(undef, "") will be true, because the left hand > side is equal to "" under string equality rules.