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."
prints nothing.use List::Util qw[ first ]; my $a = { 0 => 0 }; my $b = { 0 => 0 }; if( first{ exists $b->{ $_ } } keys %$a ) { print "Common keys!"; }
In Section
Seekers of Perl Wisdom