Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
more useful options
 
PerlMonks  

Re: Re: Comparing hashes without sorting the keys

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 18, 2004 at 23: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 12: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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.