[Chicago-talk] Using Storable to exchange data between 2 processes

Steven Lembark lembark at wrkhors.com
Thu Jan 22 10:43:25 CST 2004

> After reading the Storable.pm doc.  I can see how I could store a
> datastructure to a file, and read from that file in a different process to
> reconstruct that data structure.  But I don't see how you'd do it with
> out a file.

The shared memory module uses Storable for anything that
gets put into shared memory segments.

You can also use it for messages. Any of:

	my $payload = storable $blah;

	my $payload = Dumper $blah;

	my $payload = freeze $blah;

allow you to:

	Parallel::Pvm::pack $payload;

and have the item stuffed into the body of a message.

The nice thing about PVM is that it deals with most of the
message passing init sections, finding hosts, setting up
sockets, and whatnot. It also runs as a user-space process
so that you don't need SU to run things in a cluster. Its
pack and unpack sub's will happily stuff the result of
storing, freezing, or Dumping a structure.

Again, the main issue is making sure that you don't try
to pass things that don't travel well: file handles (vs.
paths or URI's), sockets, anon subs and closures, or
offsets into local arrays that may not have been built
identically between the machines (nice thing about hashes).


Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 888 359 3508

More information about the Chicago-talk mailing list