2

I'm no Perl expert, so this is probably an easy question.

I've been using Storable, and following this example to store a hash. First, I store the original hash.

use Storable qw(store retrieve freeze thaw dclone);
%color = ('Blue' => 1, 'Red' => 0.8, 'Black' => 0, 'White' => 1);
store(\%color, 'mycolors');

Then I retrieve it. (different script)

use Storable qw(store retrieve freeze thaw dclone);
$colref = retrieve('mycolors');
printf "Blue is still %lf\n", $colref->{'Blue'};

My question is how can I change one of the hash values? For example, do something like

$colref->{'Blue'} = 2;
store(\%color, 'mycolors');

in the second script.

4

1 回答 1

6

需要改变

store(\%color, 'mycolors');

store($colref, 'mycolors');
于 2012-04-15T19:26:29.647 回答