in reply to printing hashes

I'm not sure of the techincal/lingual reasons, but I point you at the perlop manpage that states:
For constructs that do interpolate, variables beginning with ""$"" or ""@"" are interpolated, as are the following escape sequences.

As for printing, I would recommend something like one of the following (I'm assuming the printing is basically for debugging purposes):
use Data::Dumper; print Dumper \%hash; print join ":", %hash; print join ":", keys %hash; print join ":", values %hash; while( my ($k, $v) = each %hash ){ printf " %s --> %s\n", %k, $v; }

Replies are listed 'Best First'.
Re^2: printing hashes
by gam3 (Curate) on May 06, 2005 at 02:17 UTC
    My favorite is:
    print join(', ', map { $_ . ' => '. $hash{$_} } keys %hash), "\n";
    -- gam3
    A picture is worth a thousand words, but takes 200K.
      i absolutely agree with you, but propose to sort the hash keys prior to mapping the result:
      print join(', ', map { $_ . _ => ' . $hash{$_} } sort { $a cmp $b } ke +ys(%hash), "\n";


      @ anonymus monk:
      the sort block is what sort() performs automatically, so it's just a placeholder for any other sorting routine.
      perldoc -f sort will give you some examples and advices.

      language is a virus from outer space.