in reply to Re^3: variable has value but then become empty
in thread variable has value but then become empty

Yes tried that. I can print the variable to the screen as long as I am in the same code block. Once I leave the code block the variable becomes empty.
  • Comment on Re^4: variable has value but then become empty

Replies are listed 'Best First'.
Re^5: variable has value but then become empty
by AnomalousMonk (Archbishop) on Sep 09, 2015 at 22:13 UTC

    If you can print the variable immediately before you leave the block and see the value you expect, then print the variable immediately after you leave the block and see a different value, that strongly suggests a "masking variable" situation like the ones discussed by 1nickt here and sundialsvc4 here.

    IOW: You have a lexical variable defined within a statement block (a lexical scope) that has the same name as a variable defined outside the block. You assign to and print the variable inside the statement block, but that variable goes away when execution leaves the block, at which time you are left with the outside variable and whatever value it has. I can only suggest you carefully examine your code.


    Give a man a fish:  <%-{-{-{-<