Use Data::Dumper to print contents of any data structure in Perl

This function is very useful to know the contents of any Perl data structure e.g. hashes, arrays, and also variables.

use File::Spec;
 GetOptions(\%args,
 "subscr=s",
 "action=s",
 "evttyp=s",
 "resnam=s",
 "startt=s",
 "stoptt=s",
 "adrbse=s"
 ) or die "Invalid arguments";
 print Dumper(\%args);

Produces:

$VAR1 = {
 'subscr' => 'ons',
 'startt' => '5',
 'stoptt' => '6',
 'adrbse' => '7',
 'resnam' => '4',
 'evttyp' => '3',
 'action' => '2'
 };

It’s pretty much like the debugger output.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s