Not sure if I have enough info, but the following seems to work for me on Windows XP, ActiveState Perl 5.8.9.
use strict; use warnings; use Data::Dumper; my $filename = 'hashref.txt'; my $hashRef = {a => '1', b => '2'}; open my $FH, '>', $filename or die "Unable to open $filename for output: $^E\n"; print $FH Dumper $hashRef; close $FH; my $testdata; # Since I'm using 'strict', must declare $VAR1 as it is used in # the dump file. my $VAR1; open $FH, '<', $filename or die $!; { local $/; # Not sure what this line is for # $DB::single=1; $testdata = eval <$FH>; } close $FH; while (my ($key,$value) = each(%$testdata)) { print "$key $value\n"; } # # This is what the file hashref.txt looks loke # __DATA__ $VAR1 = { 'a' => '1', 'b' => '2' };
HTH, Ken
In reply to Re: Reading in a dumped hash reference works in the perl debugger but not in the code.
by Ken Slater
in thread Reading in a dumped hash reference works in the perl debugger but not in the code.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |