develooper Front page | perl.beginners | Postings from March 2002

Re: Data::Dumper documentation ?

Thread Previous | Thread Next
From:
Chas Owens
Date:
March 19, 2002 01:59
Subject:
Re: Data::Dumper documentation ?
Message ID:
1016531771.24669.16.camel@tert.icallinc.com
On Tue, 2002-03-19 at 04:11, maasha@image.dk wrote:
> hi
> 
> i have read the documentation on Data::Dumper from Learning Perl, Perl Cookbook and perldoc. however, im still very confused. im looking for some beginners documentation and examples. can anyone direct me?
> 
> :o)
> 
> martin

perldoc Data::Dumper will get you the full docs, but this should suffice
for simple uses:

given the hash

%hash = (
	this    => 'that',
	hork    => 'up',
	funny   => 'fvbklejrbnvkbe',
	subtree => {
		name    => 'file',
		handler => 'on_file_activate',
	},
	array   => [ qw(this is an array of words) ],
);

You could say

print Dumper(\%hash);

and get

$VAR1 = {
          'subtree' => {
                         'handler' => 'on_file_activate',
                         'name' => 'file'
                       },
          'hork' => 'up',
          'funny' => 'fvbklejrbnvkbe',
          'this' => 'that',
          'array' => [
                       'this',
                       'is',
                       'an',
                       'array',
                       'of',
                       'words'
                     ]
        };

you could also say

print Data::Dumper->Dump([\%hash], [qw(new_hash)]);

and get

$new_hash = {
              'subtree' => {
                             'handler' => 'on_file_activate',
                             'name' => 'file'
                           },
              'hork' => 'up',
              'funny' => 'fvbklejrbnvkbe',
              'this' => 'that',
              'array' => [
                           'this',
                           'is',
                           'an',
                           'array',
                           'of',
                           'words'
                         ]
            };

and even go so far as saying 

eval Data::Dumper->Dump([\%hash], [qw(new_hash)]);
print "$new_hash->{funny}\n";

and get

fvbklejrbnvkbe


-- 
Today is Pungenday the 5th day of Discord in the YOLD 3168
Pzat!
Today is also Mojoday
Missile Address: 33:48:3.521N  84:23:34.786W


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About