Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(ar0n) Re (2): How to test equality of hashes?

by ar0n (Priest)
on Jun 20, 2001 at 16:06 UTC ( [id://89972]=note: print w/replies, xml ) Need Help??


in reply to andye Re: How to test equality of hashes?
in thread How to test equality of hashes?

PS If anyone can tell me how to get this hash-flattened-into-an-array behaviour without a sub, I'd be interested. I've been fiddling around with the syntax trying to get that.
if ( "@{[%hash1]}" eq "@{[$hash2]}" ) { # foo ... }


ar0n ]

Replies are listed 'Best First'.
Re: (ar0n) Re (2): How to test equality of hashes?
by aufflick (Deacon) on Sep 14, 2004 at 06:42 UTC
    None of these repsonses sort the array. I would have thought that this solution would be flakey unsorted since hashs can come out in any order they please...

    I do flattening for comparison by shoving a hashref into an array ( @foo = %{$foo} ) and then sorting the array ( @foo = sort @foo ) and flattening that into a string.,p> The obvious problem with this is that if you have a hash where the keys/values were transposed then it would still appear equal. Similar situations will occur with other data anomolies.

    Not a problem in my case, but worth remembering.

Log In?
Username:
Password:

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

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

    No recent polls found