in reply to Why is my loop dropping alphabetic strings?

Whatever you are trying to do, that's not the way to do it! You seem to be trying to perform an end run around using symbolic references, but hiding that in a string eval doesn't actually "fix" the problem, and introduces all the nastiness of string eval on top of the nastiness of symbolic references.

Instead simply use %ENV wherever you would have used your "local" variables. The content of %ENV is "local" in any case - any changes you make to the content of %ENV only affects your executing script.

By attempting to copy environment variables to local variables you are introducing two types of nasty coding practise, you are obscuring where the values actually come from, and are making it harder to change the script in the future by requiring the introduction of "local" variables for each environment variable you may want to use. So don't do that.

The immediate problem with your code is that the right hand side of the assignment operator is whatever the contents of $ENV{$NB_VAR} is. If the contents are not numeric then the rhs of the assignment will be at best a bareword and often will simply be syntactically incorrect.

True laziness is hard work

Replies are listed 'Best First'.
Re^2: Why is my loop dropping alphabetic strings?
by DiabeticJim (Initiate) on Jun 23, 2012 at 02:20 UTC

    Thank you. I appreciate your help and your advice.