@foo = (1, 2); $h{"_bar"} = \@foo; $ref = $h{"_bar"}; print "Ok: ", join(', ', @$ref), "\n"; require DB_File; tie %h, "DB_File", "test.db"; @foo = (1, 2); $h{"_bar"} = \@foo; $ref = $h{"_bar"}; print "Bork: ", join(', ', @$ref), "\n";
The result:
Ok: 1, 2 Bork:
What I expect:
Ok: 1, 2 Bork: 1, 2
What am I not getting right?
#Perl
(Please contact me if you want to remove your comment.)
⁂
@foo = (1, 2); $h{"_bar"} = \@foo; $ref = $h{"_bar"}; print "Ok: ", join(', ', @$ref), "\n"; use Storable qw( freeze thaw ); require DB_File; tie %h, "DB_File", "test.db"; @foo = (1, 2); $h{"_bar"} = freeze(\@foo); $ref = thaw($h{"_bar"}); print "Bork: ", join(', ', @$ref), "\n";
– dave 2009-03-19 02:05 UTC
---
When I went to bed later that day, I thought that this might be the problem, but it was late, and I did not have time too look at the code ever since. I didn’t know about Storable. This looks exactly like what I’m looking for. Thanks!
– Alex Schroeder 2009-03-19 07:22 UTC