Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Common hash keys

by lodin (Hermit)
on Jun 08, 2008 at 06:32 UTC ( #690897=note: print w/ replies, xml ) Need Help??


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.

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
Here you should just stick with my.

lodin


Comment on Re^3: Common hash keys
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://690897]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-12-22 04:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls