opaltoot has asked for the wisdom of the Perl Monks concerning the following question:
the dowhile goes into a continual loop when Data::Dumper or Data::Printer are called
originally took this to be a Data::Dumper issue, found it also in Data::Printer, so must be this code...
use strict; use warnings; use Data::Dumper; use Data::Printer; # perl v5.22.1 # Linux 4.4.0-137-generic #163-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Lin +ux # print $Data::Dumper::VERSION ."\n"; # v2.172 # print $Data::Printer::VERSION ."\n"; # 0.40 my $hash = {}; my $self = {}; $self->{a} = { b => $hash }; $self->{b} = $hash; dowhile($self); # comment this line to prevent continual output dofor($self); sub dowhile { my $self = shift; while (my ($k, $v) = each %{$self->{a}}) { # print Dumper $self->{a}; # uncomment line for continual output p $self->{a}; # uncomment line for continual output } } sub dofor { my $self = shift; for my $k (keys %{$self->{a}}) { p $self->{a}; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data::Dumper and Data::Printer continual output (each side effects)
by LanX (Saint) on Oct 22, 2018 at 13:23 UTC | |
by opaltoot (Novice) on Oct 22, 2018 at 14:03 UTC |