From: Jerry D. Hedden Date: Mon, 6 Nov 2006 08:57:04 +0000 (-0800) Subject: Re: [PATCH] [perl #40668] Data::Dumper fails to dump all hash keys when itertaor... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6686524f4a322ce27e0eebf255af3fb3431796c;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] [perl #40668] Data::Dumper fails to dump all hash keys when itertaor is not at start From: "Jerry D. Hedden" Message-ID: <20061106165704.939.qmail@web30214.mail.mud.yahoo.com> p4raw-id: //depot/perl@29224 --- diff --git a/ext/Data/Dumper/Dumper.pm b/ext/Data/Dumper/Dumper.pm index 44b8023..4efc17a 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 9026ae8..42931ee 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'); +}