Keep It Simple, Stupid | |
PerlMonks |
Re: A few Perl OOP questions.by Zaxo (Archbishop) |
on Oct 20, 2003 at 05:25 UTC ( [id://300476]=note: print w/replies, xml ) | Need Help?? |
my $class = ref( $type ) || $type;
That sets $class to the string returned from ref. If that return is false ($type is not a reference), $class is set to the value of $type. That code is used to intuit a class name from an instance of the class, so a class method many be called as if it were an instance method. That is an idiom which is disparaged these days as too admissive of bugs. $self->{ hireDay }->setDate( @_ ); $self is a reference to a hash. Its 'hireDay' key contains an object with an instance method called setDate. That method is called with the current argument array. my $self = $class->SUPER::new(); $self is make to be an instance of the first parent class having a new() class method. It$self will likely soon be re-blessed into $class, perhaps with some additional initialization. After Compline,
In Section
Seekers of Perl Wisdom
|
|