|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re: perl oop conceptby dsheroh (Parson) |
| on Dec 04, 2012 at 10:16 UTC ( #1007049=note: print w/ replies, xml ) | Need Help?? |
|
Try it and see. As written, this won't compile under strict because $self doesn't exist outside of new, so I've removed that. The $self from within new is returned as its output and assigned to $obj, so I think where you wrote $obj->{$self}, you really just meant $obj. With that minor adjustment and adding a call to Data::Dumper to show what's in $obj, the code becomes and produces the output Of course, as already mentioned, it would be much better OO practice to create an accessor for avalue instead of working directly with the object's internals, but at least you now know a way to see whether your objects contain the data you expect them to.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||