use warnings; sub recurse { my $i = shift; return if $i == 0; recurse($i-1); } sub tailless_recurse { my $i = shift; return if $i == 0; @_ = ($i-1); goto &tailless_recurse; } print "recursing\n"; recurse(200); print "tailless_recursing\n"; tailless_recurse(200);
This produces the following output:
recursing Deep recursion on subroutine "main::recurse" at /tmp/p line 7. tailless_recursing
Note that the second one doesn't produce the deep recursion warning.
In reply to Re: Tail Recursion in Perl
by Anonymous Monk
in thread Tail Recursion in Perl
by stvn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |