Add use strict; use warnings; at the start of every script you write. They will save you time! In this case the two errors in your hash assignment would have been flaged. One at compile time (two as a bareword) and the other at run time (the reference as 'Reference found where even-sized list expected').

and in the interests of TIMTOWTDI:

use warnings; use strict; use Data::Dumper; use Data::Dump::Streamer; my %hash = (this => 'one', that => 'two'); print "Dumpered:\n" . Dumper (\%hash); print "\nStreamered:\n"; Dump (\%hash); print "\nikegamied:\n"; foreach my $key (keys %hash) { my $val = $hash{$key}; print("$key => $val\n"); } print "\nGrandFathered:\n"; print "$_ => $hash{$_}\n" for keys %hash; print "\nmapped:\n"; print map {"$_ => $hash{$_}\n"} keys %hash;

Prints:

Dumpered: $VAR1 = { 'that' => 'two', 'this' => 'one' }; Streamered: $HASH1 = { that => 'two', this => 'one' }; ikegamied: that => two this => one GrandFathered: that => two this => one mapped: that => two this => one

DWIM is Perl's answer to Gödel

In reply to Re: dumping a hash by GrandFather
in thread dumping a hash by herby1620

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.