I'm using Perlscript and ASP on WindowsNT and IIS (sigh!). I want to use the ASP $Application object to store frozen (serialized) objects so I can have them available anywhere within my app. The problem I have is that the <emph>dear</emph> IIS object won't store characters greater than 127. The
freeze function in
Storable always returns characters greater than 127. I've worked around this problem by
uuencodeing and
uudecodeing the frozen objects before and after saving into the $Application object, but this takes very long since my objects are large. From a benchmark I made, uudecoding an object (a three level hash with 17,000 items) takes 0.6 seconds, whereas
thawing it only 0.05.
If I can get rid of the uudecode time this technique would buy me a speedup of 20x, since the alternative (regenerating objects each time from a database) takes <emph>very</emph> long.
Should I hack into Storable and make it freeze to 7 bit characters? (please see testcase at bottom)
I am experiencing these woes in part because I was expecting Perscript on IIS to cache pre-compiled scripts and module data in memory, like mod_perl does, but is not the case. (I've also tried ActiveState's PerlEx, but stumbled upon rock trying to make it stop generating headers automatically (so cookies can be sent to clients) and support for fixing this form ActiveState was close to nil). Thanks in advance!
<%@ Language=PerlScript %>
<%
use Storable qw(freeze thaw);
use Convert::UU qw(uuencode uudecode);
my %h = (llave1=>'valor1',
llave2=>{llave3=>'valor3'});
my $h_froz = freeze \%h;
$main::Application->Contents->SetProperty('Item',
'prueba_app',
$h_froz
);
my $h_recup = $main::Application->Contents('prueba_app');
$result = 'RESULTS:';
foreach(0 .. length $h_con) {
my $ch1 = substr $h_con, $_, 1;
my $ch2 = substr $h_recup, $_, 1;
if (ord($ch1) == ord($ch2)) {
$result .= "$_ SAME " . ord $ch1;
} else {
$result .= "$_ DIFFERENT " . ord ($ch1) . '-' . ord ($ch2);
}
$result .= '<BR>';
}
%>
<html>
<body>
result: <%= $result %>
</body>
</html>
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.