Friday, March 29, 2013

Dump variable value in perl

You can use Data::Dumper to print out the values stored in a perl variable similar to var_dump in php.
Data:Dumper should come as part of your standard perl distribution, so you don't need to install it.
If not, you can install it easily using cpan, such as

cpan install Data::Dumper

Usage Example:

use Data::Dumper;

my $var = (
a => 'value1',
b => 'value2',
);

print Dumper($var);