in reply to REAL Basic Perl OOP Questions
On #1, your right arrow usage is wrong.
You're putting an extra argument into your new call. The Message->new syntax causes 'Message' to appear as the first argument. Your $objType argument causes "Message" to appear as the _name element of the object instance. Call new like this: my $message_obj = Message->new($name, $subject, $message );
The name method should be called as my $name2 = $message_obj->name(); The expression Method->name($message_obj) calls name with two arguments; name('Method', $message_obj). The string "Method" is going into the $self slot and then name tries to dereference it as the object, which has been ignored.
After Compline,
Zaxo
|
|---|