数据显示
执行 use Data::Show; 时会自动导出 show 功能。此函数将变量作为其唯一参数,并输出:
- 变量的名称
- 该变量的内容(以可读格式)
- 运行 show的文件行
- 文件 show从中运行
假设以下是文件 example.pl 中的代码:
use strict;
use warnings;
use Data::Show;
my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
my %hash  = ( foo => 1, bar => { baz => 10, qux => 20 } );
my $href = \%hash;
show @array;
show %hash;
show $href;
perl example.pl 给出以下输出:
======(  @array  )=======================[ 'example.pl', line 11 ]======
    [1 .. 10]
======(  %hash  )========================[ 'example.pl', line 12 ]======
    { bar => { baz => 10, qux => 20 }, foo => 1 }
======(  $href  )========================[ 'example.pl', line 13 ]======
    { bar => { baz => 10, qux => 20 }, foo => 1 }