From: Nick C. <ni...@cl...> - 2002-04-13 09:14:32
|
On Sat, Apr 13, 2002 at 12:09:43AM +0100, Nicholas Clark wrote: > > > > my $thing; > > > > rewrite_file($filename, sub > > { > > # code to munge $_. $thing is used, so this sub > > # is a closure. > > }); > > > What do we think ? > > It's not a stated goal of nms to make the scripts easily mod-perl-able, is it? Not specifically, but IMO they should be mod_perl friendly unless it causes huge problems. > Because IIRC the my $thing; and closure breaks running the script under > Apache::Registry (if I remember that name correctly), because of the way > it wraps your script inside another subroutine. I've just replaced a lot of file scoped lexicals with globals in guestbook.pl, and it now runs without warnings under Apache::Registry. One of the two calls to rewrite_file is still using a closure over a sub scoped lexical: sub log_write { my $found_close_body = 0; rewrite_file($guestlog, sub { ... $found_close_body = 1; ... }); } ... and it's doing the right thing under Apache::Registry as far as I can see. -- Nick |