in reply to Instance field access from private methods

perrin is eminently right. Object Oriented Perl is based on three little rules, one of which states that methods are just subroutines which always receive a reference to the instance implementation (usually, but by no means always, a blessed hash) as their first argument. We might be misunderstanding what you are saying, but if you are passing $self (the ref to the instance) around yourself, something's wrong and you're not doing OO Perl.

And, again as perrin says, stay out of the symbol table if you don't know what you're doing - there be dragons there. Not that I know what I'm doing or have let that little fact stop me from messing around with the symbol table myself, but be warned that I have holes in my feet as a consequence.

A very good book (well, the book really) on Object Oriented Perl is, amazingly enough, Object Oriented Perl, by the_damian, aka Damian Conway.

One of the pieces of advice in this book is that it is a good idea that even your private methods use the class' public accessor methods to get at private instance attributes. That way, there's no frustating hunting through your code when you change the implementation of one of your attributes.

CU
Robartes-

  • Comment on Re: Instance field access from private methods