Skip to content

Commit

Permalink
Release 1.08; don't put _ into dumped ints.
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Nov 29, 2006
1 parent fedc66c commit adf98dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
19 changes: 19 additions & 0 deletions Changes
@@ -1,3 +1,22 @@
2006-11-29 Gisle Aas <gisle@ActiveState.com>

Release 1.08

By popular demand; don't put underscore into dumped integers
to group thousands.



2006-11-24 Gisle Aas <gisle@ActiveState.com>

Release 1.07

Remove unused code.

Add some more tests.



2004-11-12 Gisle Aas <gisle@ActiveState.com>

Release 1.06
Expand Down
13 changes: 3 additions & 10 deletions lib/Data/Dump.pm
Expand Up @@ -7,7 +7,7 @@ require Exporter;
*import = \&Exporter::import;
@EXPORT_OK=qw(dump pp);

$VERSION = "1.07"; # $Date$
$VERSION = "1.08"; # $Date$
$DEBUG = 0;

use overload ();
Expand Down Expand Up @@ -181,15 +181,8 @@ sub _dump
if (!defined $$rval) {
$out = "undef";
}
elsif ($$rval =~ /^-?[1-9]\d{0,8}$/ || $$rval eq "0") {
if (length $$rval > 4) {
# Separate thousands by _ to make it more readable
$out = reverse $$rval;
$out =~ s/(\d\d\d)(?=\d)/$1_/g;
$out = reverse $out;
} else {
$out = $$rval;
}
elsif ($$rval =~ /^-?[1-9]\d{0,9}$/ || $$rval eq "0") {
$out = $$rval;
}
else {
$out = quote($$rval);
Expand Down
6 changes: 3 additions & 3 deletions t/dump.t
Expand Up @@ -11,10 +11,10 @@ ok(dump("abc"), qq("abc"));
ok(dump(undef), "undef");
ok(dump(0), "0");
ok(dump(1234), "1234");
ok(dump(12345), "12_345");
ok(dump(12345678), "12_345_678");
ok(dump(12345), "12345");
ok(dump(12345678), "12345678");
ok(dump(-33), "-33");
ok(dump(-123456), "-123_456");
ok(dump(-1.5), "\"-1.5\"");
ok(dump("0123"), qq("0123"));
ok(dump(1..5), "(1, 2, 3, 4, 5)");
ok(dump([1..5]), "[1, 2, 3, 4, 5]");
Expand Down

0 comments on commit adf98dc

Please sign in to comment.