http://www.perlmonks.org?node_id=968088

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have the following code:
use 5.010; my %hash = (a => 1); given(\%hash){ # first true #given('a'){ # all true when('a' ~~ $_){ say "explicit ~~"; continue; } when($_ ~~ 'a'){ say "reversed explicit ~~"; continue; } when('a'){ say "implicit ~~"; } }
It is known that 'key' ~~ \%hash returns true if 'key' exists in %hash.

From the above code, when('a'){...} should return true because the key 'a' exists in %hash.

I see this as a perl bug. - Please correct me if I'm wrong.

My solution is when('a'){...} to be equivalent with when('a' ~~ $_){...}.
(In perl v5.14.2, it is equivalent with when($_ ~~ 'a'){...} - which in this case is wrong