in reply to calling a method within a constructor
sub new { my $class = shift; my $device = shift; my $self = { 'device' => $device, }; bless $self, $class; $self->setInformation($device); return $self; }
There's nothing particularly magical about bless -- you can call it in the middle of the constructor with no ill effects, as long as you remember to explicitly return the object you created.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: calling a method within a constructor
by ocs (Monk) on Apr 11, 2007 at 08:44 UTC | |
by dragonchild (Archbishop) on Apr 11, 2007 at 11:34 UTC |