> say "@{[%hash]}";
> since it appears to be dereferencing an array.
That's because the [...] creates an anonymous array ref and the %hash is expanded to a list inside.
I'd say this is cargo cult, say "%hash"; should have the exact same effect.
I was wrong, it helps adding white-space through $"
#!/usr/bin/perl use strict; use warnings; use feature 'say'; my %hash = (); $hash{name} = 'Michelle'; $hash{age} = 22; $hash{city} = 'Austin'; say "1: @{[%hash]}"; say "2: %hash"; say "3: ",%hash; say "4: ", join $",%hash;
1: city Austin name Michelle age 22 2: %hash 3: cityAustinnameMichelleage22 4: city Austin name Michelle age 22
but I'd certainly prefer Data::Dumper or Data::Dump here, or at least say join " ", %hash
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
In reply to Re: Print the contents of a hash without looping.
by LanX
in thread Print the contents of a hash without looping.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |