On 2010-09-25 13:07, John W. Krahn wrote:
Dr.Ruud wrote:
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 ) {

Why? Either way will work and the while loop will use less memory.

Oops, thanks for the correction, I forgot about the each-in-scalar-context mode.

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to