Subject: | Data::Dumper::Dump returns lexical variable with minus sign in name |
This problem report is reference to this CPAN Testers report for PDL:
http://www.nntp.perl.org/group/perl.cpan.testers/2009/07/msg4806234.html
The PDL test for PDL::IO::Dumper uses Data::Dumper::Dump as
a first pass to construct a valid dump file for PDL objects.
Here is an example of the Dump::Dumper::Dump output that is
expected:
print Data::Dumper->Dumpperl([{a=>3,b=>pdl(4),c=>xvals(3,3),d=>xvals
(4,4)}]);
$VAR1 = {
'c' => bless( do{\(my $o = 8181704)}, 'PDL' ),
'a' => 3,
'b' => bless( do{\(my $o = 8179968)}, 'PDL' ),
'd' => bless( do{\(my $o = 9281920)}, 'PDL' )
};
Which is then massaged into this (correct code):
print $s = sdump({a=>3,b=>pdl(4),c=>xvals(3,3),d=>xvals(4,4)});
{my($VAR1);
my($PDL_8177104) = (double(0,1,2,0,1,2,0,1,2)->reshape(3,3));
my($PDL_12634208) = (double(0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3)->reshape
(4,4));
$VAR1 = {
'c' => $PDL_8177104,
'a' => 3,
'b' => ( double(4) ),
'd' => $PDL_12634208
};
}
However, for the test reported, the output of Data::Dumper::Dump
(a.k.a. Dumpperl) is:
# Failed test 'Can eval dumped data code'
# at t/dumper.t line 49.
# The output string was '{my($VAR1);
# my($PDL_-1151577840) = (double(0,1,2,0,1,2,0,1,2)->reshape(3,3));
# my($PDL_-1151577664) = (double(0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3)-
Show quoted text
>reshape(4,4));
#
#
# $VAR1 = {
# 'c' => bless( do{\(my $o = '-1151577840')}, 'PDL' ),
# 'a' => 3,
# 'b' => bless( do{\(my $o = '-1151578016')}, 'PDL' ),
# 'd' => bless( do{\(my $o = '-1151577664')}, 'PDL' )
# };
#
# }'
Note the generation of lexical variables named $PDL_-1151577840
which is not a valid variable name. I looked at the Data::Dumper
version 2.121_08 code and saw that the name is constructed using
$Config::Config{uvxformat} so it appears the perl in the test
may be using an older version of Data::Dumper.
If this used to be a problem, do you know what version of Data::Dumper
fixed the problem?
Thanks much,
Chris