No, don't use globals.  I'm pretty sure (read: too lazy to test) that 
you can send an anonymous subroutine like this:


my $localobject = new MyTwigClass($catalog_timestamp);
twig_handlers => {
'Catalog' => sub { return $localobjext->get_catalog_timestamp(); },
}


$localobject will not get garbage collected when it is out of scope 
because it's still referenced by the anonymous subroutine.




Jeremy Muhlich wrote:
> On Fri, 2007-08-24 at 19:32 -0400, Alex Brelsfoard wrote:
>
>   
>> sub main {
>>      my $catalog_timestamp;
>>     
> ...
>
>   
>> sub get_catalog_timestamp {
>>     
> ...
>   
>>      $catalog_timestamp = $elt->att('PublishTimestamp');
>>     
>
>   
>> "Global symbol "$catalog_timestamp" requires explicit package name"
>>     
>
> Yep.  You can get away with accessing those lexicals in a function when
> your "main" code is at the top level in the script.  But when you have
> the variable declarations inside one function, the other function can't
> see them.
>
> I would do away with main, moving the code out into the top level.  If
> you *really* have your heart set on your main function (why???), you
> could move just the declarations of the "global" variables outside of
> it.
>
>
>  -- Jeremy
>
>  
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> http://mail.pm.org/mailman/listinfo/boston-pm
>
>   

-- 
Sincerely       *Duane Bronson*
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://www.nerdlogic.com/
453 Washington St. #4A, Boston, MA 02111
617.515.2909

 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to