On Fri, 2005-02-11 at 12:48 -0700, der.hans wrote: > Am 11. Feb, 2005 schwätzte Ben Weatherall so: > > > Sorry for having to reply from a Gates-based system, it is all I have > > access to at work)... > > Well, upgrade $ENV{ 'WORK' } ;-). > > > Remember that perl has a nasty feature of automatically instantiating > > any hash entry referenced in a test. In other words, if( $ENV{ > > 'USERADMIN_USER' } ) { will cause the USERADMIN_USER entry in the %ENV > > hash to come into being with a null or undefined value, even if it did > > NOT exist prior to the test. In some perl's even the following does not > > keep it from being instantiated, if ( defined($ENV{ 'USERADMIN_USER' } ) > > && $ENV{ 'USERADMIN_USER' } ) { > > You're talking about auto-vivification ( man pages are nice ), but that > shouldn't affect if() as undef still evaluates to false for if(). > > You are correct, though, that using defined() is a better practice. > > defined() will also auto-vivify. > > lufthans@dth:~$ perl -e 'if( $ENV{ 'FRED' } ) { print "fred\n"; } else { > print "nope\n" } if( $ENV{ 'FRED' } ) { print "anke\n"; } else { print > "nope\n"; } if( $ENV{ 'FRED' } ) { print "udo\n"; } else { print "nope\n"; > }' > nope > nope > nope > lufthans@dth:~$ perl -e 'if( $ENV{ 'FRED' } ) { print "fred\n"; } else { > print "nope\n" } if( exists( $ENV{ 'FRED' } ) ) { print "anke\n"; } else { > print "nope\n"; } if( defined( $ENV{ 'FRED' } ) ) { print "udo\n"; } else > { print "nope\n"; }' > nope > nope > nope > lufthans@dth:~$ perl -e 'if( $ENV{ 'FRED' } ) { print "fred\n"; } else { > print "nope\n" } if( defined( $ENV{ 'FRED' } ) ) { print "anke\n"; } else > { print "nope\n"; } if( exists( $ENV{ 'FRED' } ) ) { print "udo\n"; } else > { print "nope\n"; }' > nope > nope > nope ---- somewhere in this there may be the answer and given the beauty of perl code, I can't decipher most of it... I know with a shell script, I can insert a command like... /bin/env > /tmp/env.txt to dump my current variable list to a file. It would truly help my debugging of perl if I knew how to do the same thing in perl. Thanks Craig --------------------------------------------------- PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us To subscribe, unsubscribe, or to change you mail settings: http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss