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);
}
}