in reply to Setting values for undefined environment variables

I would do this
#!/usr/bin/perl @wanted = qw(BAD OSTYPE TZ TERM); foreach $val (@wanted) { if ($ENV{$val}) { print "$val \t is \t $ENV{$val}\n"; } else { print "$val \t is \t undefined\n"; } }
GIVES:
BAD is undefined OSTYPE is OpenBSD TZ is undefined TERM is xterm

Replies are listed 'Best First'.
•Re^2: Setting values for undefined environment variables
by merlyn (Sage) on Oct 24, 2004 at 10:47 UTC