All Scripts backed by 10 years in business, free support, free updates and a 30 day money back guarantee.
Download Purchase Programming F.A.Q. Support Contact
Commercial Perl Scripts
All Form Pro Updated
Count It
Form Mailer + Attachments
Client File Manager
Da Godfaddah
Dropbox Updated
FAQ Builder
HT Manager Updated
RegisterHT
Mailing List Server
Page Updater - Text
Page Updater Pro Updated
PS Guestbook Updated
PS Lightning Search Updated
Quick File Mailer
Quick MySQL
Select-A-File
Upload Center
Free Perl Scripts
Access Log Viewer
All Form
Epoch Converter
Error Log Viewer
Invoice Center
PS Upload
Question Manager
Quick CHMOD
QuickHT
Site File Finder
Site File Lister
SSI Tag Maker
Perl Modules
Monger Calendar
Monger File
Monger Mail
Monger Persist
JavaScript Generators
PopUp Windows
Meta Gen
RGB / Hex Converter
Page Colors
Sudoku
Tutorials and FAQs
Cookies
Using CuteFTP
Using WS_FTP
Installing Scripts
Debugging
Utilities
env_vars.pl
backup.pl
restore.pl
check_email.pl
date.pl
dayname.pl
fileage.pl
format_length.pl
format_url.pl
getfile.pl
parse.pl
redirect_html.pl
Free Services
Epoch Converter
TLD Registries
RGB/Hex FInder
Colour Checker
ASCII Codes
Policies
Terms and Conditions
Privacy Policy
Refund Policy
Site Map

Form Processor with no SPAM from robots.

Anti-spam, anti-robot, anti-flame, Guestbook for your website.

Manage Remote websites from your website. Allow clients to update sections of their own web pages.

Secure file manager with upload progress meter. A printer's best friend. Find out more.

MongerPersist

MongerPersist is a Perl module that simplifies the emulation of state retention between successive calls to a CGI script written in Perl.

MongerPersist is a self contained module that does not require any other modules to function. It was written to be placed in your webspace with the program calling it. It does NOT have to be installed on the server. Simply place it in the same directory as the program calling it.

Because of the way the web works with the HTTP protocol and the way browsers and servers interact, it is not possible to maintain state between successive calls to a program. What that means is that if you are interacting with a program, each time you click the send button in your HTML page, it is a brand new request to the server even if you've been going through a whole procedure of inter activity with the program.

With Perl programs, there are several methods of emulating a state retention on successive calls. Mainly, hidden form fields, cookies, temporary files on the server. MongerPersist looks at the last option (temporary files) and makes the job a whole lot easier for you. Instead of opening files, reading them, chomping data and closing files, then having to repeat the entire process before the program exits so the data from this call to the program can be stored, use MongerPersist.

MongerPersist makes this entire operation painless and easier to integrate. Your program code will probably be smaller and it's easy to implement. Here is an example. Assume that you are storing information entered in web forms through several pages of an ordering system. Near the end of the program I want to validate the e-mail address before I proceed any further. Here is how you would do it the long way (without MongerPersist):
if(open(FH, "<$Data/temp/$COOKIE{sessionid}.txt")) {
    flock(FH, 2);
    my @temp = <FH>;
    close FH;
    chomp @temp;
    my $email;
    foreach(@temp) {
        if($_ =~ /^email\|/) {
            (undef, $email) = split(/\|\|/, $_);
            last;
        }
    }
    if(check_email($email)) {
        #proceed with the program
You can see that in this sample there are thirteen lines of code and it takes up 303 bytes. Now have a look at a sampling of code doing the exact same thing with MongerPersist:
my $info = new MongerPersist($Data, $COOKIE{sesionid});
if(check_email($info->read('email'))) {
    #proceed with the program
You can see we've gone down to two lines of code and only 95 bytes. Big deal you say? Multiply that by 30 calls to open and close a temporary file(s) in your program.

I have another module called MongerFile that makes file manipulation quick an easy as well. However, MongerPersist is focussed more on the content of the file than the file itself. MongerPersist treats the entire file content as one big associative array (or a hash). It lets you store and retrieve hashes simply without iterating through each element.

Here is a list of the methods available in this module and a brief description of them. Full documentation on all methods is included in the module itself at the end of the file.
  1.      $obj->id;
    Retrieve, specify or change the unique id being used by the object.

  2.      $obj->path;
    This method simply returns the path that was set when you created the object.

  3.      $obj->error;
    Returns any error message set by the object.

  4.      $obj->store($key, $value);
    Tells the object to store a key and value in memory.

         $obj->store_hash(%somehash);
    Same thing but for a whole hash.

  5.      $obj->read;
    Extracts a value that you stored.

         $obj->read_hash;
    Extracts all values you returned as a hash.

  6.      $obj->peek;
    Tests a stored value and returns true if it contains an alpha-numeric character and false if it doesn't.

  7.      $obj->list;
    Since all information is stored as keys and values, this will return a list of the keys used to store information.

  8.      $obj->remove;
    Removes a single key/value pair from the objects memory.

  9.      $obj->period;
    Specifies how long the information stored in the object will be retained. The default value is one hour (3600 seconds).

  10.      $obj->save;
    For those who like to tinker, this saves the data for the next instance of the program, however, it's not needed sind the object automatically saves it's stored data when it goes out of scope.

  11.      $obj->done; Use this when your program is all done with the user and their stored data. This should be used to better manage disk space but if you don't, no problem. Every time an object goes out of scope, it sweeps it's specified storage directory and deletes any session files that have expired.

Download MongerPersist.pm
  ©2009 All rights reserved, PerlServices.net. Website hosting by LinuxHostingPlans.com