in reply to Re: Setting values for undefined environment variables
in thread Setting values for undefined environment variables

if ($ENV{$val}) {
That's a truth test, not a defined-ness test or existence test. I think you want:
if (defined $ENV{$val}) {
there, or else you'll be saying "undefined" for envars that are 0 or empty.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.