zing:

It's not enough to simply include Data::Dumper, you actually have to call it. Add print Dumper(\%HoA),"\n"; to the end of your script to let it help you out.

The slightly longer answer is this: If you want to display the structure of the data, you have to treat different data items differently. So you'd have to create a subroutine that would look at the data and handle each type differently, something like:

sub print_thing { print join("\n", _thing_helper(shift)),"\n"; } sub _thing_helper { # return a list of strings representing the thing we're given my $thing = shift; # ok, what is it? if (ref $thing eq "ARRAY") { return "array [", # Turn each thing in the list into a string map( { _thing_helper($_) } @$thing ), "]"; } elsif (ref $thing eq "HASH") { return "hash {", # Turn each thing in the array into a string map( { "$_ =>" . _thing_helper($$thing{$_}) } keys %$thing) +, "}"; else { # A good solution would also do something with objects... return "$thing"; } }

But after writing something like this, you'll probably only wind up with your own customer version of Data::Dumper anyway. But the point is that when you print a string or number, perl knows what you want: it prints the text representation of the value. For something that's a reference to some other thing, though, there are too many different ways to format the data for perl to pick out a good one for you. So it settles for telling you *what* the thing is, and a token that lets you tell whether it's the same item as another one you printed. There are different ways to display arrays, hashes and objects, so there are different packages to handle them.

Notes:

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Problem printing/storing hash by roboticus
in thread Problem printing/storing hash by zing

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.