This page is to instruct on the procedures of storing and retrieving variables, objects, or just otherwise information that you do not want to reprocess again.!

Perl module: Storable

Main functions:
store
retrieve

Store (Exporting)

Exporting or storing a perl object, variable, module, or anydata that needs to stay between runs is easy.  You just need to include a simple module and will gain access to two major functions.  The function for storing is store.

use Storable;

# build object here.  No sense in storing an empty object
store \$scalar, 'file';
store \@array, 'file';
store \%hash, 'file';
store \$object, 'file';

Retrieve (Importing)

Importing or retrieving a perl object, variable, module, or what you previously stored is easy.

use Storable;

# object will be overwritten on load, if necessary.
my $scalar = retrieve 'file';
my @array = @{retrieve 'file'};
my %hash = %{retrieve 'file'};
my $object = retrieve 'file';
# add information to object here

Note: When storing an object, the file will be overwritten.  You can either combine multiple object into a single hash or you can use multiple files if needed.



This information was acquired from http://www.perlmonks.org/?node_id=510202 with the intent to help with valuable information and is deemed to be very useful.  Use at your own discretion.