Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: useful depth of sub routines

by kcott (Abbot)
on May 27, 2013 at 19:18 UTC ( #1035454=note: print w/ replies, xml ) Need Help??

in reply to useful depth of sub routines

G'day JockoHelios,

"I'm wondering how far, or how deep, this can go without causing Perl to upchuck."

The default recursion depth for subroutines is 100. You can change this by compiling perl with -DPERL_SUB_DEPTH_WARN=n. This was introduced in 5.10.1 (see perl5101delta). You can temporarily ignore the limit with "no warnings 'recursion';" (see perldiag). Searching for "PERL_SUB_DEPTH_WARN" in both of those documents would be the quickest way to locate the relevant information.

"example: in the subroutine SRE_SubRoutineExample, all named variables and arrays start with SRE_ - thus, my $SRE_CompString = "JAPH";"

my variables declared within a subroutine are lexically scoped to that subroutine. You can have a $CompString in every subroutine you write and they will all be different variables. I think you'll probably be creating a rod for your back if you start trying to assign unique prefixes to every variable you declare in every subroutine. It's your back, though :-)

-- Ken

Comment on Re: useful depth of sub routines
Select or Download Code
Re^2: useful depth of sub routines
by JockoHelios (Scribe) on May 28, 2013 at 16:12 UTC
    Up to now, using the subroutine-specific variable names has made it easier for me to keep track of what's happening to which variable at what point in the program.

    But at this point I only have a dozen or so subroutines. I see your point - this could get hairy as that number increases. I'll eventually have to keep track of the initials of the subroutine names, to keep the variable prefixes unique. Hoo, boy.

    Dyslexics Untie !!!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035454]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2014-11-24 12:49 GMT
Find Nodes?
    Voting Booth?

    My preferred Perl binaries come from:

    Results (141 votes), past polls