in reply to Strange behavior with List::Util qw{first} on perl >= 5.20
Hmmmm... Perl v5.20:
$ perl -MList::Util=first -le 'print first {lc eq "abc"} keys %{{ABC=>"ABC"}}' abc $ perl -MList::Util=first -le 'print first {uc eq "ABC"} keys %{{ABC=>"ABC"}}' ABC $ perl -MList::Util=first -le 'print first {/abc/i} keys %{{ABC=>"ABC"}}' ABC $ perl -MList::Util=first -le 'print first {lc eq "abc"} values %{{ABC=>"ABC"}}' ABC $ perl -MList::Util=first -le 'print first {lc eq "abc"} "ABC"' ABC $ perl -MList::Util=first -le 'print first {lc eq "abc"} values @{["ABC"]}' ABC
On v5.10 they all (except for the last one) give "ABC". The inverse case, first {uc eq "ABC"} keys %{{abc=>"abc"}}, also gives the "unexpected" result "ABC". Smells like a bug... could this be rt://96343?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange behavior with List::Util qw{first} on perl >= 5.20
by Anonymous Monk on May 26, 2015 at 23:09 UTC | |
by ikegami (Patriarch) on May 27, 2015 at 14:42 UTC |