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

Re: Smartmatch two cents (was... List::Util... when...)

Thread Previous | Thread Next
From:
Eric Brine
Date:
July 3, 2012 10:53
Subject:
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
CALJW-qGPtxtmhnA-cDoj_oDU7Ec0K27ZJ+ve45Afm3qoOf2PSw@mail.gmail.com
On Tue, Jul 3, 2012 at 12:52 PM, Ed Avis <eda@waniasset.com> wrote:

> David Mertens asked:
>
> >Why would "$a in %hash" be equivalent to "exists $hash{$a}"?
>
> This is how it works in Python, and it seems natural in Perl too.
> You could write '$a in values %hash' if you wanted that.
>

Actually, you couldn't with the previously mentioned syntax. It would be

    $a in @{[ values %hash ]}

Or using the later suggested shortcut, it would be

    $a in [ values %hash ]

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