Data::Dumper
1.1、Data::Dumper简介
是什么 ?:stringified perl data structures, suitable for both printing and eval.
开发语言:Perl
metacpan:https://metacpan.org/pod/Data::Dumper
1.2、通过包管理器安装Data::Dumper
操作系统包管理器安装命令
Allcpancpan -i Data::Dumper
Allcpanmcpanm Data::Dumper
CentOSyumsudo yum install -y perl-Data-Dumper
dnfsudo dnf install -y perl-Data-Dumper
openSUSEzyppersudo zypper install -y perl-Data-Dumper
1.3、Data::Dumper API
1.3.1、$dumper = Data::Dumper -> new(valueArrayReference[, nameArrayReference])

创建Data::Dumper实例。

示例:

my $baseInfo = {name => "fpliu", age => 20, height => 180.5};
my $saySomthing = [{dateTime => "2020/02/05 15:30:00", text => "I Love you!"}];

use Data::Dumper;
my $dumper = Data::Dumper -> new([$baseInfo, $saySomthing], ["baseInfo", "saySomthing"]);
1.3.2、$str = $dumper -> Dump()

得到格式化化的字符串。

示例:

my $str = $dumper -> Dump();
print $str;