in reply to Accessing Variables in Different Subroutines

I can't replicate your problem. I added a "both" action to the dispatch table that calls both the subroutines:
both => sub { select_language(); select_animal(); }

Then I ran your code with action=both and lo and behold! The value was the same in both the subroutines.

Do you expect the value to be the same for different runs of the script?

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Accessing Variables in Different Subroutines
by stefl (Acolyte) on Mar 19, 2015 at 15:49 UTC

    I'm expecting it to be different in different runs of the script, but the subroutines need to be run sequentially (this is a much-simplified example of my code). When you run this script as it is, do the $randomString and $file variables have the same value throughout the form? For me the values change after each "Continue".

      Sure, because clicking "Continue" runs the script again. You should read more on HTTP.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Oh, I understand now. I knew it'd be something stupid. Thanks very much!