in reply to Comparing all keys in a hash
Of course I know you're not suppose to rely on hash order but would two hashes with the same keys return in the same order? I would think so but don't know (And don't have time to test) but if it did you could skip the sort. But it probably would be a bad idea.sub compare_keys { my ($h1,$h2); my ($k1,$k2) = ( join('',sort keys %$h1), join('',sort keys %$h2) ) +; return $k1 eq $k2 ? 1 : 0; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Comparing all keys in a hash
by BrowserUk (Patriarch) on Mar 20, 2003 at 14:15 UTC | |
by shotgunefx (Parson) on Mar 20, 2003 at 14:40 UTC | |
Re: Re: Comparing all keys in a hash
by Helter (Chaplain) on Mar 20, 2003 at 14:48 UTC | |
Re: Re: Comparing all keys in a hash
by rinceWind (Monsignor) on Mar 20, 2003 at 14:35 UTC | |
by shotgunefx (Parson) on Mar 20, 2003 at 19:14 UTC | |
Re: Re: Comparing all keys in a hash
by diotalevi (Canon) on Mar 20, 2003 at 18:40 UTC | |
by shotgunefx (Parson) on Mar 20, 2003 at 19:10 UTC |