HI, probably you know this trick... (send this node to the Reaper)
I am an Junir OOPerl programmer. Problem is
How implement an easy and fast Object persistence trought cgi scripts?
mmmh this my solution is a little bit unsecure :-)
Solution:
use Data::Dumper!
Here an example:
On the fisrt script I generate a big object called $probeset
(something like:
$probeset = Probeset -> new)
At the end of the first Script I have stored a lot of informations into this object...
sending all this DATA with a POST could be a crazy thing so...
First script: Dump Object
use Probeset; # that is my module
use Data::Dumper;
my $store = Data::Dumper -> Dump ([$probeset], [qw(probeset)]);
open (DUMP, "> $file);
print DUMP $store;
close DUMP;
And now the file DUMP contain an hash of this format:
$probeset = bless( {
'_genechip' => 'Human Genome U133A Array',
'_probeset_id' => '1007_s_at',
'_affy_date' => '2004-12-07',
'_chipcode' => 'HG_U133A',
[ ...}
'_trans_id' => '????',
'_exons_num' => '????',
'_organism' => 'Homo sapiens'
}, 'Probeset' );
Second Script take the DUMPED object and Eval IT
use Probeset;
open (DUMP, "< $tempdump") or die "Can't open dumping file!";
my $obj='';
my $line;
while ($line = <DUMP>) {
$obj .= $line;
}
my $probeset;
eval $obj;
And you made the Trick!Now the second script have in memory the same object that we have generated into the first script with the same Data.
The Only problem that I have notice in this snippet is this:
Object Dumping generate a File, so speed is probably dependent of your hard disk speed!
Regards Davide Rambaldi
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.