|XP is just a number|
Saving and Loading of Variablesby madbombX (Hermit)
|on Jul 18, 2006 at 03:31 UTC||Need Help??|
madbombX has asked for the
wisdom of the Perl Monks concerning the following question:
I am running a script that runs through a logfile, parses it and perpetually tails it so I can continually accrue data and maintain information over an extended period of time. However, since it is a logfile, the data can get VERY large and thus the data structures inside of Perl are holding a lot of information.
Just for general information, the data structures are a small hash, an extremely large hash (with thousands of values) and a fairly large sized array of arrays.
The problem is that I don't have a way of saving state (or reloading state if the script terminates or is terminated). Therefore, I ask what is the most efficient way of accomplishing this. I am not a fan of simply using Data::Dumper and dropping it out to a text file every X minutes and then reading that back in on script load. Suggestions are welcomed and appreciated. Thanks.
Update: I think I need to clarify my objective here with specifics. I thoroughly appreciate all the answers thus far, but here is a better idea of what I am doing and hopefully that will aid the answers.
I am sorting the maillog with postfix and spamassassin and amavisd information. I am using the spam hit scores to create a graph using GD::Graph (and that is where the LARGE array of arrays comes in). I am then using the SPAM tests that each message fails to build a hash of which tests fail more frequently than others and which tests fail in combination with each other (this builds an extremely large and slightly complex hash as it has all the SPAM tests as hash keys at the minimum and then hashes of hashes of combinations). I am doing alright with visualizing the structure (although there may be better ways to accomplish what I am doing). (If there are better ways, I am all ears) I am just not sure how I would accomplish storing them in a DB. I use DBI::mysql a lot and I am familier with that but I am having trouble conceptualizing how I would stick that in a MySQL DB. It just doesn't seem like it would apply here.