Acme-State
view release on metacpan or search on metacpan
--- #YAML:1.0
name: Acme-State
version: 0.03
abstract: Save application state on exit and restores state on startup
author:
- Scott Walters <scott@slowass.net>
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
requires:
Devel::Caller: 0.1
no_index:
directory:
lib/Acme/State.pm view on Meta::CPAN
END {
STDERR->print("Acme::State: Saving program state!\n\n");
save_state();
};
=head1 NAME
Acme::State - Save application state on exit and restores state on startup
=head1 SYNOPSIS
use Acme::State;
our $t;
print "t: $t\n";
$t = int rand 100;
print "new t: $t\n";
... and then run it again.
=head1 DESCRIPTION
Crawls the package hierarchy looking for C<our> variables.
Stores them all off in a file in the home directory of the user running the script.
When the script using this module starts up, this same file is read in and the
variables are restored.
Serializes scalars, hashes, and arrays declared using C<our>, C<use vars>, or otherwise
not declared using C<my>.
Uses L<Storable> to write the data.
The save is placed in the home directory of the user the script is executing as.
The file name is the same as the script's name (C<$0>) plus ".save".
It also keeps one backup around, named C<$0.save.last>, and it may leave a
C<$0.save.new> if interrupted.
lib/Acme/State.pm view on Meta::CPAN
=head1 SEE ALSO
You *could* use an ORM, and wind up translating all of your data to a relational schema you
don't care about or else have it automatically mapped and completely miss the point of
using a relational database.
You *could* just store your data in the Ether with Memcached.
You could C<INSERT> and C<UPDATE> manually against a database to store every little tidbit and factoid
as they're computed.
You could use BerekelyDB, including the build-in legacy C<dbmopen> and mangle everything
down to a flat associative list.
You could use L<Data::Dumper> to write a structure to a file and C<eval> that on startup
and keep all of your precious application data in one big datastructure and still not be able to
persist entire objects.
You could use C<dump> and keep waiting for the day that someone finally writes C<undump>.
But what's the fun in that?
None of those are one C<use> line and then never another thought.
That's like work for something.
Work is for suckers.
We're Perl programmers.
If it's not automatic, it's not worth doing.
( run in 0.271 second using v1.01-cache-2.11-cpan-0d8aa00de5b )