in reply to value of returned array, and remember variable in recursive function
To have a value persist between invocations of a subroutine, you can use a variable that exists outside the scope of the subroutine. There are various ways to do this, one of which is as follows. I added a limit on recursion.
use strict; use warnings; testFunc(); { my $i = 0; sub testFunc { $i++; print "$i\n"; testFunc() if($i <10); } }
|
|---|