PApp::Env - communicate between processes and the outside.
use PApp::Env; # See also PApp::Prefs and PApp::Session
This module can be used to get and set some kind of "environment" variables shared between all papp applications. When inside a PApp environment (e.g. inside a papp program) this module uses PApp's state database handle. Outside the module it tries to open a connection to the database itself, so it can be used e.g. from shell script to communicate data asynchronously to the module.
If you pass in a reference, the Storable module (Storable) will be used to serialize and deserialize it.
Environment variable names (often referred as key in this document) are treated case-insensitive if the database allows it. The contents will be treated as opaque binary objects (again, if the database supports it).
The only database supported by this module is MySQL, so the above is currently true in all cases.
Sets a single environment variable to the specified value. (mysql-specific ;)
Unsets (removes) the specified environment variable.
Return the value of the specified environment value
Locks the environment table against modifications (this is, again, only implemented for mysql so far), while executing the specified block. Returns the return value of BLOCK (which is called in scalar context).
Modifies the specified environment variable atomically by calling code-ref with the value as first argument. The code-reference must modify the argument in-place, e.g.:
modifyenv { $_[0]++ } "myapp_counter";
The modification will be done atomically. modifyenv returns whatever the BLOCK returned.
modifyenv
Returns a list of all environment variables (names).
- should also support a tied hash interface. - setenv requires mysql (actually the replace sql command), but it's so much easier & faster that way.
PApp.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
To install PApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PApp
CPAN shell
perl -MCPAN -e shell install PApp
For more information on module installation, please visit the detailed CPAN module installation guide.