Skip Menu |

This queue is for tickets about the Data-Dump CPAN distribution.

Report information
The Basics
Id: 63270
Status: rejected
Priority: 0/
Queue: Data-Dump

People
Owner: Nobody in particular
Requestors: mila [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: strings containing numbers are dumped as numbers
strings containing numbers are dumped as numbers. example: code: dd({ year => 2010, string => "1234" }); output: { string => 1234, year => 2010 } expected output: { string => '1234', year => 2010 } this is an big issue e.g. when debugging an mongodb find statement because mongodb handles numbers and strings different. ps: Data::Dumper and JSON::XS handle this case correct.
At the Perl level there isn't really any semantic distinction¹ between "1234" and 1234; so there is no good test for a perl-only module to determine if SvPOK, SvIOK or SvNOK is set. Do you know any? ¹) I know the bitwise operators makes a distinction; but that's more of a hack than anything else.
On Sun Oct 02 07:15:05 2011, GAAS wrote: Show quoted text
> At the Perl level there isn't really any semantic distinction¹ between > "1234" and 1234; so there is no good test for a perl-only module to > determine if SvPOK, SvIOK or SvNOK is set. Do you know any? > > ¹) I know the bitwise operators makes a distinction; but that's more > of a hack than anything else.
Sorry for butting in. To reiterate, the OP needs: % perl -MData::Dump -e'dd {num=>1, str=>"2"}' { num => 1, str => 2 } to become: % perl -MData::Dump -e'dd {num=>1, str=>"2"}' { num => 1, str => '2' } This should not be too hard to implement, since Data::Dumper already does this: % perl -MData::Dumper -e'print Dumper {num=>1, str=>"2"}' $VAR1 = { 'str' => '2', 'num' => 1 }; As for testing this, isn't a simple string equality test of the dump sufficient?
Sorry, never mind. Data::Dumper uses XS. I'll shut up now.