Basically I'm a bit stumped by how perl lets us reuse code snippets.  I
can't seem to bend modules to what I need to do exactly:

I'm using Apache and mod_perl.  Each perl script will produce a dynamic web
page.  Now, with each script I need to recover the session variables I'm
saving (using Apache:Session:File) and also verify account name and
password:

############################################################################
#####
use vars qw(%session);
eval { tie %session, 'Apache::Session::File', $authid, { Directory =>
'/tmp/sessions' } };
if ($@) { print redirect("LOGIN.pl?CAUSE=FailedSessionTie"); exit; }
if (time() > $session{expire_time}) { print
redirect("LOGIN.pl?CAUSE=TIMED_OUT"); exit; }
$session{expire_time} = time() + SURVEYDESIGN::survey_expire();
############################################################################
#####

Basically this chuck of code that I want to replicate across scripts is
going to grow/shrink/change rapidly in the coming weeks as I toy with the
project.

My problem seems to be that I can not include/inherit a chunk of text, but
rather need to place code in a separate package for reuse.  But I don't see
how that allows me to recover sessions and setup variables in the main
package.

Any input (or a redirection to a good FAQ) would be very welcome!  Thanks.

Daniel Hutchison
Target Analysis Group
mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
617.583.8411

Reply via email to