Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: useful depth of sub routines

by kcott (Chancellor)
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

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2018-03-22 07:07 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (273 votes). Check out past polls.