in reply to Re: want to create a variable whise value do not get change on recursion
in thread want to create a variable whise value do not get change on recursion

Indeed, that sentence confused me. The OP might have meant when the function is called recursively ... Here is some code for the OP that shows how to maintain a "global" variable, but not how to share variables between runs of a script.

#!/usr/bin/perl use strict; use warnings; our $outer = 5; recurse($outer); sub recurse { my $inner = shift; $inner--; return if $inner < 0; print "outer: $outer\ninner: $inner\n"; recurse($inner); }

UPDATE: You make it seem so crystal clear, holli. Oh well, here is a recursive sub in case someone needs it. :D

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re^2: want to create a variable whise value do not get change on recursion
  • Download Code

Replies are listed 'Best First'.
Re^3: want to create a variable whise value do not get change on recursion
by holli (Abbot) on Feb 03, 2005 at 15:00 UTC
    The OP said my script calls itself recursively. I think that has be to taken as it was said. There may be a good reason to do that.

    holli, regexed monk