Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: Comparing hashes without sorting the keys

by samtregar (Abbot)
on Feb 18, 2004 at 23:25 UTC ( [id://330090]=note: print w/replies, xml ) Need Help??


in reply to Re: Comparing hashes without sorting the keys
in thread Comparing hashes without sorting the keys

That won't work! Try it on these hashes, which your code considers equal, for example:

my %aa=(aa=>'aa', bb=>'bb'); my %bb=(a=>'aaa', b=>'bbb');

-sam

Replies are listed 'Best First'.
Re: Re: Re: Comparing hashes without sorting the keys
by greenFox (Vicar) on Feb 19, 2004 at 04:17 UTC
    ++nicely spotted. Even just "flattening" the hash to an array is suicidal, consider
    my %aa=(aa=>'bb', cc=>'dd'); my %bb=(bb=>'aa', dd=>'cc');
    ...ouch!

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

Re: Re: Re: Comparing hashes without sorting the keys
by Popcorn Dave (Abbot) on Feb 19, 2004 at 17:30 UTC
    You're right! Given the OP's data I just hacked out a quick solution, but thanks for pointing out my flaw.

    Good call.

    There is no emoticon for what I'm feeling now.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found