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

...when script is called recursively
??? I don't know what exactly you mean by that, but I am quite wary of what it might mean.

Independent scripts simply don't share variables.

  • Comment on Re: want to create a variable whise value do not get change on recursion

Replies are listed 'Best First'.
Re^2: want to create a variable whise value do not get change on recursion
by jeffa (Bishop) on Feb 03, 2005 at 13:24 UTC

    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)
    
      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
Re^2: want to create a variable whise value do not get change on recursion
by monkey_boy (Priest) on Feb 03, 2005 at 13:27 UTC
    Yes, wary is the word, if the script get posted im expecting to see the dreaded exec in there ...




    Im so sick of my Signature...