Think about Loose Coupling | |
PerlMonks |
Blessed be the OOP'ersby jeffa (Bishop) |
on Jun 29, 2000 at 01:02 UTC ( [id://20253]=perlquestion: print w/replies, xml ) | Need Help?? |
jeffa has asked for the wisdom of the Perl Monks concerning the following question:
I am playing with objects and came across a stumbling block.
I have a Person class that appears to be correctly coded, but I will print it at the bottom of my question just in case. My problem is in the use of said class. The Person class has a data field called NAME and method to set and get it's value called name(). My client code instantiates a number of Person objects and stores them in a list: No problems here, now let's say that I want to iterate through list and print the names of my employees: Uh oh - upon trying to interpret the script, Perl yacks: Can't call method "name" on unblessed reference at ./foo.pl line xx So I changed the print statement to: and got: ARRAY Person Person Person Person Person Person Person Can anyone tell me where did that ARRAY came from? Here is my Person class as promised: (can anyone say Perltoot?) Thanks!
Back to
Seekers of Perl Wisdom
|
|