Subject: | Accidental autovivification of $ENV{TMPDIR} under Windows |
I was getting uninitialized value errors on use of %ENV. I tracked it down to the use of tmpdir() under Windows. Then tracked it down to this line in File::Spec::Win32,
$tmpdir = $_[0]->_tmpdir( @ENV{qw(TMPDIR TEMP TMP)},
This has the unintended effect of autovivifying $ENV{TMPDIR}, which environment variable is not previously defined on my system. That is, using a slice in a subroutine call will autovivify any hash values not previously defined. (I was stunned, yes, but please refer to discussion at http://www.perlmonks.com/?node_id=500136. I suppose this has been discussed to death on P5P?)
The 'fix' would be to change this to:
$tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR},
$ENV{TEMP},
$ENV{TMP},
I have tested this under Windows XP and ActiveState Perl 5.8.7 build 813 and it corrected the uninitialized errors problem I was seeing.