Hi

> 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.

edit

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.