in reply to Re: Print the contents of a hash without looping.
in thread Print the contents of a hash without looping.
Just for completenes -
say "%hash"; should have the exact same effect.
Arguably it should, but it doesn't. A hash (or a construct with sigil %) is never interpolated in double quoted strings or qq(). I guess it is because, at list expansion of a hash, the sequence of key/value tuples is random. And then, the char % is meaningful for sprintf. However, hash slices are interpolated (their sigil is @). So,
my $hash = \%hash; say "5: %$hash"; say "6: @hash{keys %hash}"; say "7: @$hash{keys $hash}";
5: %HASH(0x1185900) 6: Michelle Austin 22 7: Michelle Austin 22
|
|---|