http://www.perlmonks.org?node_id=983048


in reply to Re: Concept map of data types
in thread Concept map of data types

Thanks,

Here, in your examples I found my mistake, instead of @ I wrote %, I corrected this. Last updated map is above, you can see.

Yesterday I look for a Data::Dumper in a CPAN but I didn't undesrtand how to use it. I am new in using cpan and modules. I red SYNOPSIS but didn't understand how to use them (code). Do you have any link that help me in this case? In cpan modules till now I could use just Date::Format.

Replies are listed 'Best First'.
Re^3: Concept map of data types
by aitap (Curate) on Jul 22, 2012 at 09:10 UTC

    Data::Dumper can be used to do a lot of interesting things, but basically, you just need to use Data::Dumper and then print Dumper (anything).

    It can be useful to pass a reference to the object you want to see, not just this object. For example, it's useful in case of AoH (array of hashes):

    use Data::Dumper; my @hashes = ( { one => 1, two => 2, three => 3 }, { one => 11, two => 22, three => 33 }, ); print Dumper @hashes; print "-"x5,"\n"; print Dumper \@hashes; __END__ $VAR1 = { 'three' => 3, 'one' => 1, 'two' => 2 }; $VAR2 = { 'three' => 33, 'one' => 11, 'two' => 22 }; ----- $VAR1 = [ { 'three' => 3, 'one' => 1, 'two' => 2 }, { 'three' => 33, 'one' => 11, 'two' => 22 } ];
    ...but it does not improve anything in case of reference to array of references to arrays:
    my $reference = [ [ 7, 8, 9 ], [ 10, 11, 12 ], ]; print Dumper $reference; print Dumper \$reference; $VAR1 = [ [ 7, 8, 9 ], [ 10, 11, 12 ] ]; $VAR1 = \[ [ 7, 8, 9 ], [ 10, 11, 12 ] ];

    Sorry if my advice was wrong.
Re^3: Concept map of data types
by 2teez (Vicar) on Jul 22, 2012 at 09:28 UTC
    Hi,

    You can use Data::Dumper like so:

    use Data::Dumper; my @abc = #abc is an array of references to arrays ( [qw (q w e r)], [qw (1 x 3 r)], [qw (qwe rt 434 )], ); print Dumper ( \@abc ); ## pass array @abc as an array reference my $abc = #abc is an array reference that contains references to ar +rays [ [qw (q w e r)], [qw (1 x 3 r)], [qw (qwe rt 434 )], ]; print Dumper ($abc); ## pass the array reference

    Both print the following:

    $VAR1 = [ [ 'q', 'w', 'e', 'r' ], [ '1', 'x', '3', 'r' ], [ 'qwe', 'rt', '434' ] ];
    Showing 'stringified perl data structures'. It shows you how your data is structured.
    Hope this helps

Re^3: Concept map of data types
by Athanasius (Archbishop) on Jul 22, 2012 at 08:52 UTC
    Yesterday I look for a Data::Dumper in a CPAN but I didn't undesrtand how to use it.

    Data::Dumper is a core module, so you can view its documentation in perldoc. See especially the EXAMPLES section.

    HTH,

    Athanasius <°(((><contra mundum