The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Sure. What caught my attention was this:
Since you've got a variable called $self, I'm assuming this is an object method. What you're doing here is creating a local version of the package variable $self. So if you had a package global called $self (which you probably shouldn't) you'd be overriding it. That is generally not the behavior that you want in a method. (or any sub, really.) You want a lexical variable called $self, one which is unrelated to any other $self in any other lexical block. The reason I assumed you did not know the difference is because I saw in that code lots of locals mixed in with mys in places that did not make a lot of sense. I would write that code as:
Here's an excellent document explaining when to use each: Coping With Scoping. In reply to Re: Re: Re: Re: Re: Dereferencing an array of hash references
by mfriedman
|
|