in reply to Re^2: Hash File to Binary ?
in thread Hash File to Binary ?

zak_s:

Dumper only displays the data in readable form. The store function writes it into a file in such a way that retrieve can get it back out. Here's a quick example that stores a data structure to a file:

#!/usr/bin/perl use strict; use warnings; use Storable; # You'll get it via XMLin, I just hardcoded some data my $data = { foo=>'bar', bim=>'bam' }; store $data, 'MyFile.data';

Now, when we have another program that wants to use the data, we just retrieve it first:

#!/usr/bin/perl use strict; use warnings; use Storable; use Data::Dumper; my $ref = retrieve('MyFile.data'); print Dumper($ref);

We're only using Data::Dumper to display the data, you won't need it in either of your scripts unless you need to print it to the screen for debugging. (Which is what I often do.)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^4: Hash File to Binary ?
by zak_s (Initiate) on Dec 12, 2013 at 15:45 UTC

    Thanks a lot for all of you. Worked!
    I have no idea what I did wrong last time for this not to work even though I tried it.