[Israel.pm] bless and AUTOLOAD

Yona Shlomo yona at cs.technion.ac.il
Tue Sep 25 07:50:37 PDT 2007


I have a strange collision using bless and AUTOLOAD.

For example, here a simple Perl script, t.pl, which
demostrates my problem:

 	use strict;
 	use warnings;
 	use Data::Dumper;

 	my $t=T->new();

 	package T;


 	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.


Shlomo Yona
yona at cs.technion.ac.il

More information about the Perl mailing list