Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: mod_perl / Apache::Registry accidental closures

by imp (Priest)
on Jul 21, 2006 at 00:51 UTC ( #562748=note: print w/replies, xml ) Need Help??


in reply to mod_perl / Apache::Registry accidental closures

I'm including an abuse of the mechanism in a separate comment, because it is not directly related to the tutorial.

This is a bad thing to do, and any programmer who inherits the project from you will do horrible things to you if you use this trick

use strict; use warnings; my $foo = 5; print "Content-type: text/plain\n"; print "Content-disposition: inline; filename=foo.txt\n\n"; printf "Package: %s\n", __PACKAGE__; printf "[%s] Before: %s\n", $$, $foo; goodness(5); printf "[%s] After: %s\n", $$, $foo; } sub goodness { my $val = shift; printf "[%s] goodness: %s\n", $$, $foo; $foo += $val;
Which Apache::Registry will turn into this:
package Apache::ROOTfoo_2ecom::test_2epl; use Apache qw(exit); sub handler { #line 1 /www/foo.com/test.pl use strict; use warnings; my $foo = 5; print "Content-type: text/plain\n"; print "Content-disposition: inline; filename=foo.txt\n\n"; printf "Package: %s\n", __PACKAGE__; printf "[%s] Before: %s\n", $$, $foo; goodness(5); printf "[%s] After: %s\n", $$, $foo; } sub goodness { my $val = shift; printf "[%s] goodness: %s\n", $$, $foo; $foo += $val; }
By adding an extra '}' before the sub goodness declaration we are really closing sub handler {, and then at the end of the script we leave off the closing '}', since one will be added by Apache::Registry.

Replies are listed 'Best First'.
Re^2: mod_perl / Apache::Registry accidental closures
by rhesa (Vicar) on Jul 21, 2006 at 01:31 UTC
    My eyes! Ze goggles, zey do nothing!1!!

    Please, please, hide this behind spoiler tags :^)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://562748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2016-10-01 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.