> Tim Pushor wrote:
> 
> Is there a way to use local script variables in your cleanup code? Whatabout 
>variables/functions declared in global.ini?
> 
> I would think you could use your session or application object if you can, but I 
>don't have any need for either in this app.
> 
> I specifically need to be able to call a function declared in global.ini, and would 
>like to somehow be able to operate on objects defined in the asp
> page before it goes out of scope - i.e.
> 
> <%
>      sub handler {
>         my $n=some_magic;
>         $n->unlock
>         log failure;
>     }
> 
>     $n=new object;
>     $Server->RegisterCleanup (&handler);
>     $n->lock;
>     .. do stuff ..
>     $n->unlock;
>     log success;
> 

I believe you are on the right track, how about:

# in script
<%  
  my $n = new object;
  $Server->RegisterCleanup(sub { &handler($n) }); 
%>

# in global.asa
sub handler {
  my $n = shift || die("need \$n to handle");
  ...
}

Even if originally declared with my($n), the $n should stay in
scope until after the script ends because it was being used 
in the runtime sub {} that was installed for RegisterCleanup

Also, make sure to turn on PerlSetVar UseStrict if you have 
not done so already, as this will save you many headaches 
down the road.

-- Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to