Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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?
[karlgoethebier]: Eily: non-people == persone non grata?
[Your Mother]: Corion: I have lost the link to the pmdev guide(s). Do you have that handy?
[karlgoethebier]: Discipulus: see per lop please how to avoid the classic <c>perl dangerous.pl 'rm -rfv *|'</>
[Eily]: karlgoethebier: more like grata non persona :P
Discipulus personae non gratae..
[Corion]: Your Mother: Hmm - I have the pmdev nodelet, which has some links, but I'm not sure what links/guides there are
[Corion]: pmdev wiki maybe?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2017-07-21 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (319 votes). Check out past polls.