http://www.perlmonks.org?node_id=11259

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (subroutines)

sub sarReadDir{ &sarReadDir () }

Originally posted as a Categorized Question.

  • Comment on Can I make recursive calls to subroutines?

Replies are listed 'Best First'.
Re: Can I make recursive calls to subroutines?
by chromatic (Archbishop) on May 12, 2000 at 18:47 UTC
    Yes. Perl will even warn you if the recursion stack gets too deep (I'm currently around 200,000 calls).
    use strict; sub head_for_the_deep { my $depth = shift; print "Sinking to level $depth.\n"; head_for_the_deep($depth + 1); } head_for_the_deep(0);
Re: Can I make recursive calls to subroutines?
by BBQ (Curate) on May 14, 2000 at 05:05 UTC
    Yes indeed you can.

    It looks as if you're going to be doing a directory recursion, yes? You might want to check out this node, since its all about directory recursion and a tricky situation (which chromatic here above, shed some very good light on).
Re: Can I make recursive calls to subroutines?
by gridlock (Novice) on Feb 22, 2004 at 06:54 UTC
    Can you? Yes!
    Is it a good idea? No
    As far as possible - you should avoid making recursive calls to a subroutine.

    Originally posted as a Categorized Answer.