Discipulus has asked for the wisdom of the Perl Monks concerning the following question:
prints an inverted result:#!perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Purity =1; my %dispatch = ( original_a => sub {print "AAA\n"}, ); $dispatch{a}=\&{$dispatch{original_a}}; print Dumper(\%dispatch);
I was expecting that 'original_a' was sub { "DUMMY" } and not do{my $o}. The inversion is reaffermed using $Data::Dumper::Purity =1; that prints the last line $VAR1->{'original_a'} = $VAR1->{'a'};Encountered CODE ref, using dummy placeholder at C:/Perl/lib/Data/Dump +er.pm line 179. $VAR1 = { 'a' => sub { "DUMMY" }, 'original_a' => do{my $o} }; $VAR1->{'original_a'} = $VAR1->{'a'};
perl -MData::Dumper -e "$h{a} = sub{print qq(AAA\n)}; $h{alias} = \&{$ +h{a}}; print Dumper(\%h)" $VAR1 = { 'a' => sub { "DUMMY" }, 'alias' => $VAR1->{'a'} };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: doubts about Data::Dumper output
by choroba (Cardinal) on Oct 06, 2014 at 10:10 UTC | |
|
Re: doubts about Data::Dumper output
by LanX (Saint) on Oct 06, 2014 at 11:27 UTC | |
|
Re: doubts about Data::Dumper output
by MidLifeXis (Monsignor) on Oct 06, 2014 at 13:12 UTC | |
by Discipulus (Canon) on Oct 06, 2014 at 18:47 UTC | |
|
Re: doubts about Data::Dumper output
by Anonymous Monk on Oct 06, 2014 at 10:15 UTC | |
|
Re: doubts about Data::Dumper output
by Discipulus (Canon) on Oct 06, 2014 at 11:40 UTC | |
by LanX (Saint) on Oct 06, 2014 at 12:27 UTC | |
by Anonymous Monk on Oct 06, 2014 at 23:42 UTC | |
by choroba (Cardinal) on Oct 07, 2014 at 00:13 UTC | |
by Anonymous Monk on Oct 07, 2014 at 07:23 UTC | |
by LanX (Saint) on Oct 07, 2014 at 07:45 UTC | |
| |
by Discipulus (Canon) on Oct 07, 2014 at 07:15 UTC |