shemp has asked for the wisdom of the Perl Monks concerning the following question:
And here is the output:use strict; use warnings; use Data::Dumper; use Tie::IxHash; { tie (my %x, 'Tie::IxHash'); %x = ( 'A' => 1, 'B' => 2, 'C' => 3, ); print join "", map { "$_ = $x{$_}\n" } keys %x; print "\n"; my $dumped; { local $Data::Dumper::Terse = 1; $dumped = Dumper(\%x); } print "Dumper: $dumped\n\n"; my $y = eval $dumped; print join "", map { "$_ = $y->{$_}\n" } keys %$y; }
A = 1
B = 2
C = 3
Dumper: {
'A' => '1',
'B' => '2',
'C' => '3'
}
A = 1
C = 3
B = 2
Its obvious that the problem is in the Dumper(), not the eval, because the value of $dumped does not contain any tie information, as a dumped object instance would have.
Any easy workarounds available?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie and Data::Dumper
by kvale (Monsignor) on Jul 13, 2004 at 21:58 UTC | |
|
Re: Tie and Data::Dumper
by ysth (Canon) on Jul 13, 2004 at 22:00 UTC | |
|
Re: Tie and Data::Dumper
by DaveH (Monk) on Jul 14, 2004 at 11:24 UTC | |
|
Re: Tie and Data::Dumper
by eserte (Deacon) on Jul 14, 2004 at 14:58 UTC |