Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 127309
Status: new
Priority: 0/
Queue: Data-Dumper

People
Owner: Nobody in particular
Requestors: degatcpan [...] ntlworld.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.154
Fixed in: (no value)



Subject: looping behaviour
running attached file gives infinite (?) loop. Comment out line starting 'print Dumper' to prevent loop. Data::Dumper v2.158 perl v5.22.1 Linux 4.4.0-137-generic #163-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
Subject: loop.pl
use strict; use warnings; use Data::Dumper; # v2.158 # perl v5.22.1 # Linux 4.4.0-137-generic #163-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux my $self = {}; my $cpook = {'b' => [0, 0]}; pair($self, 'a', 0, 0, $cpook); solve($self, ['a']); sub pair { my $self = shift; my $id = shift; my @ps = @_; _pair($self, $id, \@ps); } sub _pookpair { my ($self, $id, $aref) = @_; _pair($self, $id, $aref); } sub _pair { my ($self, $id, $aref) = @_; print Dumper $self->{pairs}; # comment this line to prevent loop $self->{pairs}->{$id} = $aref; } sub solve { my ($self, $treeref) = @_; my $pairid = $self->{pairs}->{$treeref->[0]}; while (my ($k, $v) = each %{$pairid->[2]}) { _pookpair($self, $k, \@$v); } }
On Sat Oct 06 06:33:25 2018, DEG wrote: Show quoted text
> running attached file gives infinite (?) loop. Comment out line > starting 'print Dumper' to prevent loop. > > Data::Dumper v2.158 > perl v5.22.1 > Linux 4.4.0-137-generic #163-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
updated loop.pl; "while-each" loops, "for keys" behaves
Subject: loop.pl
use strict; use warnings; use Data::Dumper; # v2.158 # perl v5.22.1 # Linux 4.4.0-137-generic #163-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux my $self = {}; my $cpook = {'b' => [0, 0]}; _pair($self, 'a', [0, 0, $cpook]); solvewhile($self, ['a']); # comment this line to prevent loop solvefor($self, ['a']); sub _pair { my ($self, $id, $aref) = @_; print Dumper $self->{pairs}; $self->{pairs}->{$id} = $aref; } sub solvewhile { my ($self, $treeref) = @_; my $pairid = $self->{pairs}->{$treeref->[0]}; while (my ($k, $v) = each %{$pairid->[2]}) { _pair($self, $k, $v); } } sub solvefor { my ($self, $treeref) = @_; my $pairid = $self->{pairs}->{$treeref->[0]}; for my $k (keys %{$pairid->[2]}) { _pair($self, $k, $pairid->[2]->{$k}); } }