dumperSimple.pl
一个对调试很有用的模块,它改良了Dumper的功能。
看看下面的代码就知道了
use Data::Dumper;
my $s = "scalar";
my @a = ( "red", ["green", {yellow=>"blue"}]);
my %h = (name=>"wti", loveColor=>"blue");
print STDERR Dumper($s, \%h, \@a);
print STDERR Dumper($s, %h, @a);
#------------------------------------------------------
# The output are:
#
# $VAR1 = 'scalar';
# $VAR2 = {
# 'name' => 'wti',
# 'loveColor' => 'blue'
# };
# $VAR3 = [
# 'red',
# [
# 'green',
# {
# 'yellow' => 'blue'
# }
# ]
# ];
# $VAR1 = 'scalar';
# $VAR2 = 'name';
# $VAR3 = 'wti';
# $VAR4 = 'loveColor';
# $VAR5 = 'blue';
# $VAR6 = 'red';
# $VAR7 = [
# 'green',
# {
# 'yellow' => 'blue'
# }
# ];
#------------------------------------------------------
use Data::Dumper::Simple;
print STDERR Dumper($s, \%h, \@a);
#------------------------------------------------------
# The output are:
#
# $s = 'scalar';
# $h = {
# 'name' => 'wti',
# 'loveColor' => 'blue'
# };
# $a = [
# 'red',
# [
# 'green',
# {
# 'yellow' => 'blue'
# }
# ]
# ];
#------------------------------------------------------
print STDERR Dumper($s, %h, @a);
#------------------------------------------------------
# Outputs are same as Dumper($s, \%h, \@a)
#------------------------------------------------------