shemp has asked for the wisdom of the Perl Monks concerning the following question:
And here is the output:#!/usr/bin/perl -w use strict; use Data::Dumper; { my $hashref = { "aaa" => 1, "bbb" => 2, "ccc" => 3, }; print "hashref : " . Dumper($hashref); my $dumped = Dumper($hashref); print "Dumped: $dumped\n"; my $restored = eval $dumped; print "restored: " . Dumper($restored); my $test_2 = eval(Dumper($hashref)); print "test_2: " . Dumper($test_2); }
hashref : $VAR1 = {
'ccc' => 3,
'bbb' => 2,
'aaa' => 1
};
Dumped: $VAR1 = {
'ccc' => 3,
'bbb' => 2,
'aaa' => 1
};
restored: $VAR1 = undef;
test_2: $VAR1 = undef;
Now from all the documentation ive read, both $restored and $test_2 should contain copies of the original $hashref, but dont. Any insight would be great.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data::Dumper and eval
by perlmonkey (Hermit) on Sep 25, 2003 at 00:03 UTC | |
|
Re: Data::Dumper and eval
by broquaint (Abbot) on Sep 25, 2003 at 09:18 UTC | |
|
Re: Data::Dumper and eval
by iburrell (Chaplain) on Sep 25, 2003 at 21:24 UTC | |
|
Re: Data::Dumper and eval
by shemp (Deacon) on Sep 25, 2003 at 12:52 UTC |