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>