develooper Front page | perl.perl5.porters | Postings from July 2018

Re: hash slice assignment

Thread Previous | Thread Next
From:
Tom Molesworth via perl5-porters
Date:
July 27, 2018 09:55
Subject:
Re: hash slice assignment
Message ID:
CAGXhHd=c1uicsPVuoeMhfr0X44AKPTAij4SgJ=3ua2axe1o-=A@mail.gmail.com
On Fri, 27 Jul 2018, 5:51 pm H.Merijn Brand, <h.m.brand@xs4all.nl> wrote:

> This is perl 5, version 24, subversion 1 (v5.24.1) built for
> x86_64-linux-thread-multi-ld
>
>
> $ perl -wE'my%h=(foo=>{});$h{foo}{qw(a b)}=(1,2)'
>
> $ perl -wE'my%h=(foo=>{});$h{$_}{qw(a b)}=(1,2)for"foo"'
>

My understanding for both of these is that the value 2 is assigned, the 1
is discarded due to scalar comma, but void-context 1 is special-cased not
to warn.

$ perl -wE'my%h=(foo=>{});$h{$_}{qw(a b)}=($_,2)for"foo"'
> Useless use of a variable in void context at -e line 1.
>

... the discarded value is now something without that special case.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About