in reply to Tie and Data::Dumper

Hi.

The easiest solution is to remember that Tie::IxHash is just a normal class under the "tie" scenes. Yes, it defined a few "magic" methods (FETCH, STORE, etc), but it is still just a variable blessed into a class. You can use this property to create a Tie::IxHash object, freeze this object with Data::Dumper, then used the thawed Tie::IxHash object to create a new tied hash.

Something like this:

#!perl use strict; use warnings; use Data::Dumper qw(Dumper); use Tie::IxHash; tie (my %x, 'Tie::IxHash'); %x = ( 'A' => 1, 'B' => 2, 'C' => 3, ); print join "", (map { "$_ = $x{$_}\n" } keys %x), "\n"; my $x = Tie::IxHash->new(%x); my $dumped; { local $Data::Dumper::Terse = 1; $dumped = Dumper($x); } print "Dumper: $dumped\n"; undef $x; print "\$x is undef\n\n" unless $x; my $y = eval $dumped; tie (my %y, 'Tie::IxHash'); @y{$y->Keys} = $y->Values; print join "", (map { "$_ = $y{$_}\n" } keys %y), "\n"; __END__ A = 1 B = 2 C = 3 Dumper: bless( [ { 'A' => '0', 'C' => '2', 'B' => '1' }, [ 'A', 'B', 'C' ], [ '1', '2', '3' ], 0 ], 'Tie::IxHash' ) $x is undef A = 1 B = 2 C = 3

I hope that this helps.

Cheers,

-- Dave :-)


$q=[split+qr,,,q,~swmi,.$,],+s.$.Em~w^,,.,s,.,$&&$$q[pos],eg,print