【问题标题】:Data::Dumper::Simple usageData::Dumper::简单用法
【发布时间】:2012-06-06 11:24:49
【问题描述】:

只是感兴趣:有没有办法在下面的 sn-p 中做第二种形式的 Dumper?

use Modern::Perl;
use Data::Dumper::Simple;

my $data = { name => 'jim', age => 21, updated => time() };

my $timestr = localtime($data->{updated});
say Dumper($data->{updated}, $timestr);
# output:
# $data->{updated} = 1338537112;
# $timestr = 'Fri Jun  1 08:51:52 2012';

say Dumper($data->{updated}, scalar localtime($data->{updated} ));

# compiliation error:
# say (...) interpreted as function at c:\temp\test4.pl line 9.
# syntax error at c:\temp\test4.pl line 9, near "}]"

【问题讨论】:

    标签: perl data-dumper


    【解决方案1】:

    引用the docs:

    不要尝试使用参数列表中的子例程调用 Dumper():

    Dumper($foo, some_sub()); # Bad!

    过滤器被括号弄糊涂了。你的作者打算 解决这个问题,但很明显 Dumper() 没有办法 可以弄清楚如何命名子程序的返回值, 从而确保进一步破损。所以不要那样做。

    【讨论】:

      猜你喜欢
      • 2012-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多