Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Storable Module

by perl.j (Pilgrim)
on Aug 24, 2011 at 22:00 UTC ( [id://922216]=perlquestion: print w/replies, xml ) Need Help??

perl.j has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Storable Module
by Anonymous Monk on Aug 24, 2011 at 22:30 UTC
    It does what it purports to do :P

    Storable

    Storable - persistence for Perl data structures
    DESCRIPTION

    The Storable package brings persistence to your Perl data structures containing SCALAR, ARRAY, HASH or REF objects, i.e. anything that can be conveniently stored to disk and retrieved at a later time.

     

    ... serializing and deserializing.

    Serialization

    In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and "resurrected" later in the same or another computer environment.
    So Storable lets you save data structures to disk.

    You want to use Storable when creating these data structures is expensive, like for cpan/cpanp.

    cpanp makes sourcefiles.s2.30.c0.9109.stored out of 01mailrc.txt.gz,02packages.details.txt.gz, 03modlist.data.gz

    $ ls -loanh *gz *stored -rw-rw-rw- 1 0 181K 2011-08-24 04:05 01mailrc.txt.gz -rw-rw-rw- 1 0 1.1M 2011-08-24 04:05 02packages.details.txt.gz -rw-rw-rw- 1 0 190K 2011-08-24 04:05 03modlist.data.gz -rw-rw-rw- 1 0 23M 2011-08-16 23:06 sourcefiles.s2.30.c0.9109.stored

    and cpan makes a Metadata out of the same files

    $ ls -loanh Metadata -rw-rw-rw- 1 0 16M 2011-08-13 09:15 Metadata

    cpan/cpanp use these files, when you're checking if you have the latest version of a module, who the author is, what other modules the author has ...

    Generating the data from the tarballs on each run would be expensive (read SLOW)

    cpan/cpanp typically update these files once a day

Re: Storable Module
by cdarke (Prior) on Aug 25, 2011 at 08:18 UTC
    I have to wonder why you are looking at Storable if you don't know what it does and you don't know why you would want to use it.

    Storable is used for storing data structures, such as hashes, in a binary file format. There's more than one way to do this, for example YAML.
    A useful feature of Statable is the dclone() method, which does a deep copy of a data structure. Copying a complex data structure (hash-of-arrays, for example) using an ordinary assignment will copy the references, so something like dclone() (or Clone) is needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://922216]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-18 00:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found