Perl: the Markov chain saw | |
PerlMonks |
Re: Overridding subroutines called in private subroutinesby ikegami (Patriarch) |
on Oct 05, 2008 at 05:13 UTC ( [id://715409]=note: print w/replies, xml ) | Need Help?? |
You can't so much override a function as replace it.
Alternate syntax:
You can wrap the original function:
You can even do so temporarily:
In all cases, it's replaced for everyone. You could use caller to emulate other behaviours, perhaps.
There's no such thing as a private subroutine. The inner sub is just as public as the outer one. Whoever wrote that code was fooling himself. And he's asking for trouble. The following warning is an understated indicator of the problem of nesting named subs:
I don't know if I've answered your question since I really don't know what you're asking, but I hope I helped. Note: The BEGIN is not necessarily needed in any of the examples. Plain curlies would likely work too.
In Section
Seekers of Perl Wisdom
|
|