develooper Front page | perl.perl5.porters | Postings from June 2013

Re: key/value hash and index/valuse array slices syntax

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 11, 2013 18:49
Subject:
Re: key/value hash and index/valuse array slices syntax
Message ID:
CALJW-qGsZugJudV5d=NHf2noTVOqHZ9Ba_FcZFOYrq4N0wD47Q@mail.gmail.com
On Tue, Jun 11, 2013 at 1:21 PM, Aristotle Pagaltzis <pagaltzis@gmx.de>wrote:

> More importantly, given hash slices that *omit* non-existent keys, it is
> much harder to get the opposite behaviour. I cannot even think of any
> sensible way to do it as an expression within the same statement, only
> if I accept multiple statements, by doing such as
>
>     my %second = %first{qw/a c/};
>     @first{qw/a c/} = @first{qw/a c/};
>

Still two statements, but this is simpler:

my %second;
@second{qw/a c/} = @first{qw/a c/};

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