summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry D. Hedden <jdhedden@cpan.org>2006-11-06 00:57:04 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-11-07 11:16:54 +0000
commitd6686524f4a322ce27e0eebf255af3fb3431796c (patch)
treee33811896f159f8c319eeebeb6277d4ec082fe19
parenta0bda3fbbd18086a4b6043f125d2b181ebb3ea58 (diff)
downloadperl-d6686524f4a322ce27e0eebf255af3fb3431796c.tar.gz
Re: [PATCH] [perl #40668] Data::Dumper fails to dump all hash keys when itertaor is not at start
From: "Jerry D. Hedden" <jdhedden@yahoo.com> Message-ID: <20061106165704.939.qmail@web30214.mail.mud.yahoo.com> p4raw-id: //depot/perl@29224
-rw-r--r--ext/Data/Dumper/Dumper.pm7
-rw-r--r--ext/Data/Dumper/t/bugs.t13
2 files changed, 18 insertions, 2 deletions
diff --git a/ext/Data/Dumper/Dumper.pm b/ext/Data/Dumper/Dumper.pm
index 44b802365d..4efc17a90d 100644
--- a/ext/Data/Dumper/Dumper.pm
+++ b/ext/Data/Dumper/Dumper.pm
@@ -9,7 +9,7 @@
package Data::Dumper;
-$VERSION = '2.121_10';
+$VERSION = '2.121_11';
#$| = 1;
@@ -231,6 +231,11 @@ sub Dumpperl {
$name = "\$" . $s->{varname} . $i;
}
+ # Ensure hash iterator is reset
+ if (ref($val) eq 'HASH') {
+ keys(%$val);
+ }
+
my $valstr;
{
local($s->{apad}) = $s->{apad};
diff --git a/ext/Data/Dumper/t/bugs.t b/ext/Data/Dumper/t/bugs.t
index 9026ae8a34..42931ee746 100644
--- a/ext/Data/Dumper/t/bugs.t
+++ b/ext/Data/Dumper/t/bugs.t
@@ -16,7 +16,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 2;
+use Test::More tests => 3;
use Data::Dumper;
{
@@ -48,3 +48,14 @@ sub foo {
foo({});
ok(1, "[perl #38612]"); # Still no core dump? We are fine.
+{
+ my %h = (1,2,3,4);
+ each %h;
+
+ my $d = Data::Dumper->new([\%h]);
+ $d->Useqq(1);
+ my $txt = $d->Dump();
+ my $VAR1;
+ eval $txt;
+ is_deeply($VAR1, \%h, '[perl #40668] Reset hash iterator');
+}