[pm-h] Bitten by "Experimental keys on scalar is now forbidden" on perl 5.23.X - How not to use keys!

Julian Brown julian at jlbprof.com
Tue Jan 26 09:34:21 PST 2016


I always do the latter mechanism anyway because there is no ambiguity.   It
has bit me in the past.

Julian

On Tue, Jan 26, 2016 at 10:19 AM, Mark Allen via Houston <houston at pm.org>
wrote:

> It was my understanding that most of the "automagic dereferencing"
> behaviors are being removed because although they *usually* do what you
> mean, they sometimes do not and that leads to mysterious and difficult to
> track down bugs.
>
> Mark
>
>
> On Tuesday, January 26, 2016 10:05 AM, Robert Stone via Houston <
> houston at pm.org> wrote:
>
>
> 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
>
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/
>
>
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20160126/fbb8a7a4/attachment.html>


More information about the Houston mailing list