On 2010-09-25 01:57, Vaishnavi Saba wrote:
My query: In the code shown below, How does *grep* compare a scalar( *
$seen{$_}* ) with an array of hash references ( *...@_* ).
=====
@common = inter( \%foo, \%bar, \%joe );
sub inter {
my %seen;
for my $href ( @_ ) {
while (my $k = each %$href ) {
Replace the while-line by:
for my $k ( keys %$href ) {
$seen{ $k }++;
}
}
return grep { $seen{ $_ } == @_ } keys %seen;
}
It is meant to return the keys that are in all input hashes.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/