Skip to content

Commit

Permalink
Fix dump($1) when $1 was numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Oct 14, 2011
1 parent 97119d4 commit 6caed8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Data/Dump.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ sub _dump
if (!defined $$rval) {
$out = "undef";
}
elsif ($$rval =~ /^-?[1-9]\d{0,9}\z/ || $$rval eq "0") {
$out = $$rval;
elsif (my $v = "$$rval", $$rval =~ /^-?[1-9]\d{0,9}\z/ || $$rval eq "0") {
$out = $v;
}
else {
$out = str($$rval);
Expand Down
5 changes: 3 additions & 2 deletions t/dollar-one.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 4;
use Test::More tests => 6;

use Data::Dump qw/dump/;

Expand All @@ -11,6 +11,7 @@ if ("abc" =~ /(.+)/) {
}

if ("123" =~ /(.+)/) {
local $TODO = '$1 still modified by dump itself';
is(dump($1), "123");
is(dump(\$1), '\123');
is(dump([$1]), '[123]');
}

0 comments on commit 6caed8a

Please sign in to comment.