Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
use Storable;
$a = [100, 200, {'foo' => 'bar'}];
eval {
    store($a, 'test.dat');
};
print "Error writing to file: $@" if $@;
$a = retrieve('test.dat');

If

...

you

...

have

...

more

...

than

...

one

...

structure

...

to

...

stuff

...

into

...

a

...

file,

...

simply

...

put

...

all

...

of

...

them

...

in

...

an

...

anonymous

...

array

...

and

...

pass

...

this

...

array's

...

reference

...

to

...

store.

...

You

...

can

...

pass

...

an

...

open

...

filehandle

...

to

...

store_fd

...

instead

...

of

...

giving

...

a

...

filename

...

to

...

store.

...

The

...

functions

...

nstore

...

and

...

nstore_fd

...

can

...

be

...

used

...

for

...

storing

...

the

...

data

...

in

...

"network"

...

order,

...

making

...

the

...

data

...

machine-independent.

...

When

...

you

...

use

...

retrieve

...

or

...

retrieve_fd,

...

the

...

data

...

is

...

automatically

...

converted

...

back

...

to

...

the

...

native

...

machine

...

format

...

(while

...

storing,

...

the

...

module

...

storesa

...

flag

...

indicating

...

whether

...

it

...

has

...

stored

...

it

...

in

...

a

...

machine-independent

...

format

...

or

...

not).

...