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

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

Thread Previous | Thread Next
Eric Brine
July 3, 2012 10:53
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
On Tue, Jul 3, 2012 at 12:52 PM, Ed Avis <> 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About