[pm-h] Bitten by "Experimental keys on scalar is now forbidden" on perl 5.23.X - How not to use keys!
Robert Stone
drzigman at drzigman.com
Tue Jan 26 08:05:34 PST 2016
Greetings,
I've just released a heavily refactored version of my WWW::LogicBoxes
module to cpan (
http://search.cpan.org/dist/WWW-LogicBoxes/lib/WWW/LogicBoxes.pm), Huzzahs
are in order!
However, cpan testers pointed out an issue to me:
Experimental keys on scalar is now forbidden at
/tmp/loop_over_bdir-8387-8qtZ5O/WWW-LogicBoxes-1.0.1-syf1_3/blib/lib/WWW/LogicBoxes/Role/Command/Raw.pm
line 165.
Looking at the perldiag documentation:
*5.22*
keys on reference is experimental
(S experimental::autoderef) keys with a scalar argument is experimental and
may change or be removed in a future Perl version
*5.23*
Experimental %s on scalar is now forbidden
(F) An experimental feature added in Perl 5.14 allowed each, keys, push,
pop, shift, splice, unshift, and values to be called with a scalar
argument. This experiment is considered unsuccessful, and has been removed.
The postderef feature may meet your needs better.
*So, this code will now cause compilation failures:*
my $hashref = {
key => 'value',
};
for my $key ( *keys $hashref* ) {
print $key . "\n";
}
*And should instead be:*
for my $key ( *keys %{ $hashref }* ) {
print $key . "\n";
}
Good times!
I have to admit that the later is more explicit but I kinda feel like this
violated the spirit of perl's "Do what I mean." Is there any more
backstory, or can anyone else put forward additional reasons as to why this
functionality is being removed?
Best Regards,
Robert Stone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20160126/9d09ccb0/attachment.html>
More information about the Houston
mailing list