Data :: Dumper :: Easy to use

Just wondering: is there a way to make a second Dumper shape in this next snippet?

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 "}]"
+5
source share
1 answer

Quote documents :

Do not try to call Dumper () using a routine in the argument list:

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

The filter gets tangled up with parentheses. Your author was about to fix this, but it became obvious that there was no way that Dumper () could determine what to call return values ​​from routines, thereby ensuring further destruction. So do not do this.

+7
source

All Articles