Thanks. This addresses my problems.
Some questions:
1. why our and not my for AUTOLOAD?
2. why do I need to implement (even an empty) DESTROY sub?
Thanks, Gabor.
Shlomo
On Tue, 25 Sep 2007, Gabor Szabo wrote:
> Have you tried to print $AUTOLOAD in the AUTOLOAD function?
>
> You will notice that you have to declrae it using "our" not "my'
> and then it is called when the DESTROY method of the package is called
>
> so you need to create a
>
> sub DESTROY {
> }
>
> to avoid calling AUTOLOAD on object destruction.
>
>
> Gabor
>
> On 9/25/07, Yona Shlomo <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> I have a strange collision using bless and AUTOLOAD.
>>
>> For example, here a simple Perl script, t.pl, which
>> demostrates my problem:
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>> use Data::Dumper;
>>
>> my $t=T->new();
>>
>> package T;
>>
>> my $AUTOLOAD;
>>
>> sub new {
>> my ($class, %arguments) = @_;
>> bless {}, $class;
>> }
>>
>> sub AUTOLOAD {
>> print "why am I in AUTOLOAD?!\n";
>> }
>>
>>
>> Surprisingly, for me, when I run t.pl I get:
>> why am I in AUTOLOAD?!
>>
>> So, why am I executing code in AUTOLOAD?
>>
>> Apparently the $class is to blame in the bless statement,
>> but I don't know why and I don't know how to avoid this.
>>
>> Anyone?
>>
>> --
>> Shlomo Yona
>> [EMAIL PROTECTED]
>> http://yeda.cs.technion.ac.il/~yona/
>> _______________________________________________
>> Perl mailing list
>> [email protected]
>> http://perl.org.il/mailman/listinfo/perl
>>
>
>
>
--
Shlomo Yona
[EMAIL PROTECTED]
http://yeda.cs.technion.ac.il/~yona/
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl