[prev] [thread] [next] [Date index for 2005/03/09]
John ORourke wrote: > Question is, do anonymous subs assigned to hash values and placed in the > 'new' method get compiled every time a new object is created or just when > the module file is initially loaded? > #### if using anon subs, define them here: > $$code{type1} = sub { do something cool; } > $$code{type2} = sub { do something cooler; } > $$code{type3} = sub { do something even cooler; } The answer: it depends on whether you create a closure or not. In the case of anon-sub which acts as a closure it'll recompile each time it's encountered. Otherwise it'll be compiled once during the module loading. It's explained here: http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Understanding_Closures____the_Easy_Way You absolutely must not create closures when running mod_perl.: http://perl.apache.org/docs/general/perl_reference/perl_reference.html#my___Scoped_Variable_in_Nested_Subroutines -- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
[newbie] [mp2] when are inline/anonymous subs compiled? John ORourke 20:37 on 09 Mar 2005
Re: [newbie] [mp2] when are inline/anonymous subs compiled? Stas Bekman 20:52 on 09 Mar 2005
Generated at 08:54 on 14 Mar 2005 by mariachi v0.52