Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/motemen/script-state
Keep script local variables
https://github.com/motemen/script-state
Last synced: 3 days ago
JSON representation
Keep script local variables
- Host: GitHub
- URL: https://github.com/motemen/script-state
- Owner: motemen
- Created: 2010-11-16T04:33:17.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-11-01T15:31:51.000Z (over 13 years ago)
- Last Synced: 2024-11-30T21:11:41.967Z (2 months ago)
- Language: Perl
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
Awesome Lists containing this project
README
# NAME
Script::State - Keep script local variables
# SYNOPSIS
#!perl
use Script::State;script_state my $count = 0; # set to last value if exists
say $count++;# automatically write $count's current value to external file
# to be read at next script execution# FUNCTIONS/METHODS
- script_state my $variable = $default;
Keep this variable's state after script execution.
- Script::State->store;
Explicitly store current state. This is called in END block.
# DESCRIPTION
Script::State stores local variables to file after script execution.
Values of scalar variables with `script_state` are stored in another file,
and the values are automatically loaded when script is executed at next time.# HOW THIS WORKS
Script::State stores variable states to file at same directory of script ($0).
For example, if $0 eq 'foo/bar.pl', filename containing state is 'foo/.bar.pl.pl'.When Script::State is import()ed, it will load previous state from the state file,
and at the time script_state() is called, bind corresponding value to the variable.When Script::State's END block is entered, this stores current variable values
to the state file.# CAVEATS
This modules currently uses Data::Dumper::Dump and eval() to store/load state, maybe unsafe.
This modules currently does not lock state files.
# AUTHOR
motemen
# LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.