On 09/25/2010 01:57 AM, Vaishnavi Saba wrote: > @common = inter( \%foo, \%bar, \%joe ); > sub inter { > my %seen; > for my $href (@_) { > while (my $k = each %$href ) { > $seen{$k}++; > } > } > return grep { $seen{$_} == @_ } keys %seen; > }
Usually not a good practice to perform actions on @_ itself as it carries parameters by reference rather than by value, and you're more inclined to cause bugs further on. Common practice is to immediately assign @_, or variables in @_ to local variables: sub inter { my @hashRefs = @_; Also, as mentioned, you're not comparing anything of value in your grep, rather if any of keys %seen == 3. And since keys %seen came from @_, is there a reason for grepping over them and comparing that with @_? > > When I try printing the @_, I get the output as "HASH(0x40030354) > HASH(0x400303d8) HASH(0x40037e98)". These are the addresses of the hash-references in @_. You should try using Data::Dumper: use Data::Dumper; print Dumper(@_); #or \...@_ rather to see what is actually in the hashes. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/