sub compare_hash_keys { my ($h1,$h2) = @_; my $test; # A temporary variable for holding a result so it doesn't have to be recomputed. my @k1 = keys %$h1; my @k2 = keys %$h2; $test = @k1 <=> @k2 and return $test; for ( 0 .. $#k1 ) { $test = $k1[$_] cmp $k2[$_] and return $test; } return; }