in reply to Print the contents of a hash without looping.
> 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print the contents of a hash without looping.
by shmem (Chancellor) on Dec 02, 2017 at 11:40 UTC | |
|
Re^2: Print the contents of a hash without looping.
by BillKSmith (Monsignor) on Dec 02, 2017 at 04:23 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |