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/Linux # 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}; } }