Script::Resume

State keeper for scripts that might abort in the middle of execution but need to pick up where they left off in later invocations.
Download

Script::Resume Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Robert Powers
  • Publisher web site:
  • http://search.cpan.org/~batman/

Script::Resume Tags


Script::Resume Description

State keeper for scripts that might abort in the middle of execution but need to pick up where they left off in later invocations. Script::Resume is a state keeper for scripts that might abort in the middle of execution but need to pick up where they left off in later invocations.SYNOPSIS use Script::Resume; my $state = {Robin => "Jason Todd"}; my $rez = new Script::Resume(SCRIPT_STATE => $state, STAGES => ); $rez->addStage("oh_and_this_too", FUNC => &this_too, ALWAYS=>1); $rez->runAllStages(); print "Result: Robin = $state->{Robin} "; sub do_this { print "I'm doing this ";} sub then_that { print "I'm doing that "; $state->{Robin} = "Dick Grayson"; } sub finally_this { print "I'm finally doing this "; $state->{Robin} = "Tim Drake"; } sub this_too { print "I'm doing this too ";}Here's a script that runs it with more explicit control use Script::Resume; my $robin; my $now = time(); my $rez = new Script::Resume(); $rez->addStage("my_first_stage", FUNC => &stage_one); $rez->addStage("my_second_stage", FUNC => &stage_two); $rez->addStage("my_third_stage", FUNC => &stage_three); $robin = $rez->runStage("my_first_stage", "Jason Todd"); print "Result: Robin 1 = $robin "; $robin = $rez->runStage("my_second_stage", "Dick Grayson"); print "Result: Robin 2 = $robin "; $robin = $rez->runStage("my_third_stage", "Tim Drake"); print "Result: Robin3 = $robin "; sub stage_one { return shift;} sub stage_two { return shift;} sub stage_three { return shift;}Script::Resume Allows you to automatically break your script into stages with state such that if the script bails out in the middle somewhere, you can fix the problem, rerun the script and it'll pick up where it left off, with the previous state and all. This is useful for tasks where you can't start from the beginning again and/or you wouldn't want to, such as scripts involved in copying massive files around.State is maintained in a plain Data::Dumper format file in $ENV{TEMP}/$0.state or /tmp/$0.state (or wherever you designate) so you can tweak it before re-running. It will store the SCRIPT_STATE you pass into the constructor along with all return values from all the stages. If the stage has already been run in a previous invocation of your script, the return value will be returned without actually re-running the stage. Requirements: · Perl


Script::Resume Related Software