Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Common hash keys

by tinita (Parson)
on Jun 08, 2008 at 12:11 UTC ( [id://690916]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Common hash keys
in thread Common hash keys

List::Util::first() returns the result of the code block, in this case the boolean return of the exists function.
i think it returns the key it's iterating over, just like grep works. from the docs: "first returns the first element where the result from BLOCK is a true value."
use List::Util qw[ first ]; my $a = { 0 => 0 }; my $b = { 0 => 0 }; if( first{ exists $b->{ $_ } } keys %$a ) { print "Common keys!"; }
prints nothing.

Replies are listed 'Best First'.
Re^5: Common hash keys
by BrowserUk (Patriarch) on Jun 08, 2008 at 15:51 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://690916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found