Data::Dumper module对有些输出比较有用,比如hash,或者没有赋值的变量。
==脚本dumper_1.pl==
#!/usr/bin/perl -w
#
# dumper_1.pl
# Use of Data::Dumper module
use strict;
use Data::Dumper;
my $v1='abc';
my $v2=22;
my $v3;
my @array1=('unit1','part2',33,'four');
my %hash1=("Tom",89,"Jack",67,"Samio",77,"aa",69);
print Dumper($v1);
print Dumper($v2);
print Dumper($v3);
print Dumper(/@array1);
print Dumper(/%hash1);
==执行结果==
C:/temp1>perl dumper_1.pl
$VAR1 = 'abc';
$VAR1 = 22;
$VAR1 = undef;
$VAR1 = [
'unit1',
'part2',
33,
'four'
];
$VAR1 = {
'Jack' => 67,
'aa' => 69,
'Samio' => 77,
'Tom' => 89
};