![]() |
|
Just another Perl shrine | |
PerlMonks |
Perl's equivalent to Python's hasattr and getattr? (class variable details)by MistaMuShu (Beadle) |
on Jul 28, 2005 at 23:19 UTC ( #479170=perlquestion: print w/replies, xml ) | Need Help?? |
MistaMuShu has asked for the wisdom of the Perl Monks concerning the following question: Hi all, I'm starting to learn about Perl objects and having trouble understanding the internal workings. As I understand it, instance variables are stored in the "referenced thingy". But how does Perl do class variables? Since a 'class' is a package, is it correct to say that variables local to a package are "class variables"?
I tried this out and it seems to make sense, but I hope someone can rephrase this more articulately. The other question I have concerns how class variables are stored. I want to have a single "set" method to change class variables rather than one per variable. Something along the lines of:
In Python, I could use hasattr, getattr, and setattr to accomplish this. What's the Perl style to do it? I apologize in advance if I blurted out any rubbish or missed something searching around. Any interesting beginner links to closures, Perl object internals, and symbol tables would also be cool. I'm in the process of reading the ones in the tutorial section, but still struggling through it somewhat. Thanks all in advance.
Back to
Seekers of Perl Wisdom
|
|