in reply to Re^2: Common hash keys
in thread Common hash keys
Be careful with that state. It won't do what (I think) you want.
Here you should just stick with my.use 5.010; sub foo { my ($a, $b) = @_; sort grep { state %seen; $seen{$_}++ } keys %$a, keys %$b } my %a = ( a => 1, b => 2, c => 3 ); my %b = ( b => 2, c => 1, d => 4 ); say join ' ', foo(\%a, \%b); say join ' ', foo(\%a, \%b); __END__ b c a b b c c d
lodin
|
---|
In Section
Seekers of Perl Wisdom