|Just another Perl shrine|
useful depth of sub routinesby JockoHelios (Scribe)
|on May 27, 2013 at 18:42 UTC||Need Help??|
JockoHelios has asked for the
wisdom of the Perl Monks concerning the following question:
Thanks for your responses. I won't be doing recursive subroutine calls, at least, not intentionally :) so I probably won't crash my system with what I intend to do.
And of course, what I intend the code to do is precisely what will occur :)
I'm working on an extensive data-processing project for which Perl seems the ideal language.
As the work progresses, I'm removing repetitive sections of code into subroutines.
Looking forward, I can see that I'll be writing subroutines that call subroutines.
And then subroutines that call subroutines that call subroutines. And probably even deeper levels.
I'm wondering how far, or how deep, this can go without causing Perl to upchuck.A few preventative measures I'm already taking:
- passing large arrays to subroutines would chew up RAM, so I'm passing array references
- identifiers could become a problem within the layers, so I'm using strict
- I'm also using sub-routine specific naming conventions
- example: in the subroutine SRE_SubRoutineExample, all named variables and arrays start with SRE_ - thus, my $SRE_CompString = "JAPH";
I've found nodes for a variety of "gotchas", but not a node just for subroutine "gotchas". The calling depth, as mentioned, is one concern, but I'm interested in others that I haven't run into yet. So I'm hoping to hear about some of these and avoid them. And save a few brain cells in the process :)
Dyslexics Untie !!!