sub printh { tie my %x, 'Tie::IxHash', @_; # Recreate the hash. Expensive warn $_ for keys %x; } printh(%h); # Flatten the hash #### sub printh { my ($x) = @_; warn $_ for keys %$x; } printh(\%h); # Pass a reference