Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Common hash keys

by moritz (Cardinal)
on Jun 07, 2008 at 07:56 UTC ( [id://690807]=note: print w/replies, xml ) Need Help??


in reply to Re: Common hash keys
in thread Common hash keys

Your inner loop could be described as clubbing somebody to death with a loaded uzi. No need to iterate over the hash keys just to check if one is present. Looking up a key in a hash is the most basic operation a hash offers ;-)

Replies are listed 'Best First'.
Re^3: Common hash keys
by parv (Parson) on Jun 07, 2008 at 08:34 UTC

    (: Indeed! (But I did not write Perl, did I?)

      Maybe
      my @keys_in_commmon = grep $hashref1->{$_}, keys %$hashref2;
      would've sufficed?? If you just have to determine if they have keys in common,
      if( grep $hashref1->{$_}, keys %$hashref2 ) { ... }
      would do the trick...
        I would say  my @keys_in_commmon = grepexists($hashref1->{$_}), keys %$hashref2; to avoid autovivification.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found