Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: How best to compare hash values?

by toolic (Bishop)
on May 06, 2010 at 16:44 UTC ( [id://838748]=note: print w/replies, xml ) Need Help??


in reply to Re: How best to compare hash values?
in thread How best to compare hash values?

my %hash1 = (); # Initialize empty hash. Perhaps unnecessary?
Yes, this is unnecessary. Either:
my %hash1;

or:

my %hash1 = ( "1", "20", "2", "20", "4", "19", "5", "20", "10", "20", "6", "18");

Fat commas are nice too: 1 => 20,

I created a sub "isNull" as a homegrown replacement for "exists". The idea is to check your assumptions (and data) before you operate on that data.
Your isNull sub is not need with your data. Try:
unless ($hash2{$thisKey}) {

instead of:

if (isNull(\%hash2, $thisKey)) {

Replies are listed 'Best First'.
Re^3: How best to compare hash values?
by jimbass (Novice) on May 06, 2010 at 19:18 UTC

    Thanks for the additional code and such guys. I've come to see there's quite a few different ways of accomplishing the same thing!

    I'm working with arrays now rather than hashes, and a mis-coding on my part showed that I may not even need arrays for some thimgs, simple variables seem to capture the data too!

    I'm working now on capturing output from different short scripts, and it seems that rather than call other scripts, its best to do everything possible from a single perl script. Using strict and warnings is forcing me to do a fair amount of reading, which is helpful. Thanks again to everyone!

      Check out Net::SSH::Expect or Net::Telnet to poll your radios.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found