If I'm not mistaken, you've asked this question before. The problem is with the line
This effectively invokes the name method with two arguments: the string 'Message' and the blessed reference $message_obj. The error happens when the function attempts to use the first argument (in this case, the string 'Message') as if it were a hash reference. What you want (I think) ismy $name2 = Message->name( $message_obj );
Try that.my $name2 = $message_obj->name;
Update: Just to clarify. I don't want to give you the impression that invocations of the form Class_Name->method are always wrong. If method is a class method, that's exactly what you should do. In your example, new is a class method (and therefore Message->new(...) is correct), whereas name is an instance method. Hence the difference in the way they are invoked.
the lowliest monk
In reply to Re: Real Basic Perl OOP Problem
by tlm
in thread Reaped: Real Basic Perl OOP Problem
by NodeReaper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |