Hi Todd,

I see from Need help with loop syntax errors, that you like to experiment. I suggest that you do more of the same with Data::Dumper to empirically see what it does with various data structures.

In general you give Dumper a reference to any arbitrary structure and it figures out how to display it.

Here is some "play" code to get you started:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @data = qw( 7 8 9); my $dataref = \@data; #create reference to data array my $string = 'this is string'; print Dumper \@data; #dump using reference to @data =PRINTS $VAR1 = [ '7', '8', '9' ]; =cut print Dumper $dataref; #dump using scalar reference =PRINTS $VAR1 = [ '7', '8', '9' ]; =cut print Dumper @data; =PRINTS $VAR1 = '7'; $VAR2 = '8'; $VAR3 = '9'; =cut print Dumper $string; =PRINTS $VAR1 = 'this is string'; =cut print Dumper \$string; =PRINTS $VAR1 = \'this is string'; =cut __END__ I used a feature of Perl called perlpod - the "Plain Old Documentation +" commands to interleave multi-line printouts into the code. That is not what this is normally used for, but you will sometimes see this techni +que on PM as a way to make the code and the printout all "one Perl file" t +hat can be executed.
There is more than one module that can dump data, but Data::Dumper is "core" meaning that it is included in all Perl distributions and you can just assume that it is there without having to install anything. Have fun experimenting.

In reply to Re^3: data dumper question by Marshall
in thread data dumper question by Todd Chester

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.