in reply to updated_again: how to loop through hash tables more efficiently
A hash table lets you get a value given its name. So you don't need the second loop: You can use the exists function (see perldoc -f exists ) to check if the key is in the other hash.)
$ cat t my %h = (a=>1, b=>2, c=>3); print "a ", exists($h{a}) ? "exists" : "does not exist", "\n"; print "c ", exists($h{c}) ? "exists" : "does not exist", "\n"; print "f ", exists($h{f}) ? "exists" : "does not exist", "\n"; $ perl t a exists c exists f does not exist
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to loop through hash tables more efficiently
by Anonymous Monk on Sep 17, 2012 at 21:20 UTC | |
by roboticus (Chancellor) on Sep 18, 2012 at 15:32 UTC |