SPUG: method call during object construction

Umar Cheema umar at drizzle.com
Wed Feb 15 15:06:13 PST 2006

I was hoping to make this work:

my $obj = Class->new('class_name')->change_name('new_class_name');

But after the constructor call $obj simply holds the value returned by the 
'change_name' method.

Of course the following works just fine:

my $obj = Class->new('class_name');

Can someone explain what is going on with the first way of calling a 
method during construction? Is this something we're not suppose to do or 
am I just seeing weird perl behavior for some other reason?


More information about the spug-list mailing list