>>>>> "PJ" == Peng, Jeff <p...@l.nsbeta.info> writes:

  PJ> Dump the data structure for printing.
  PJ> It's useful for checking the complex data strucure of Perl.

  PJ> For example,

  PJ> use Data::Dumper;

  PJ> my %hash = ( 1 => [1,2,3,4],
  PJ>              2 => { 1 => { 2 => [3,4,5] } },
  PJ>            );

  PJ> print Dumper \%hash;

  PJ> Run it and see what is printing.

that is a very important use in debugging. i use it all the time when i
want to see what data structure i have actually built and compare it to
what i think i should have built.

it has other uses too. it can be used to serialize data (though with
some caveats) for sending to other programs (also other modules can do
that with some advantages). it can be used to save data (e.g. a config
file) in a file for reloading in the future (via running the dumper
output with eval). there are other uses but those are the most
common. knowing it should be a core skill for any perl hacker. it is
easy to use but you do need to learn your refs to quickly understand its
output. read perldoc perlreftut, perllol and perldsc for more on perl
refs and data structures. understanding the output of dumper will make
it easier to write code that navigates your structures.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to