On 9/25/07, Yona Shlomo <[EMAIL PROTECTED]> wrote:
> Thanks. This addresses my problems.
> Some questions:

I tried to find some pointers in perldoc but I could not come up
with anything comprehensive perlbot, perlsub and perltoot have
something about it

>
> 1. why our and not my for AUTOLOAD?
the real $AUTOLOAD is a package global so you need to treat it that way.
if you declare it with "my" you get a lexically scoped variable that
will hide the
real one.

> 2. why do I need to implement (even an empty) DESTROY sub?
because it is called when the object goes out of scope and if you have
an AUTOLOAD method it will catch it.
You can of course say
return if $AUTOLOAD =~ /::DESTROY$/;

in your AUTOLOAD method but I find it more descriptive to declare an empty
DESTROY method. Sometime I even add a comment saying

# to avoid triggering AUTOLOAD


Gabor
Perl Training Israel
http://www.pti.co.il/
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to