On Wed, Jun 01, 2011 at 09:07:45AM -0700, eventual wrote: > use Data::Dumper; > > Hi, > Can someone give me a few examples on the purpose of use Data::Dumper; > I tried reading but I could not understand. > Thanks
Data::Dumper is a useful modules for converting perl data structures into a string for printing. It can be used for debugging, understanding how somebody else's code works, tranffering information, etc. The full docs for the module can be found at <http://search.cpan.org/perldoc?Data::Dumper>. Here's a simple example: #!/usr/bin/perl use 5.010; use strict; use warnings; use Data::Dumper; my @foo = ( 'one', 'two', 'three' ); my %bar = ( 'redfish' => 'bluefish', 'onefish' => 'twofish' ); my $more_complex = [ { foo => 'bar', 'baz' => 'biz' }, 'two', { a => 'b', c => [ 'one', 'two', 'three' ] } ]; say Data::Dumper->Dump( [ \@foo, \%bar, $more_complex ], [ 'foo', 'bar', 'more_complex' ] ); Produces this output: $foo = [ 'one', 'two', 'three' ]; $bar = { 'onefish' => 'twofish', 'redfish' => 'bluefish' }; $more_complex = [ { 'baz' => 'biz', 'foo' => 'bar' }, 'two', { 'c' => [ 'one', 'two', 'three' ], 'a' => 'b' } ]; --- END -- Hopefully this is useful. Mike -- Michael mich...@thegrebs.com M: +1-562-MIKEGRB -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/