Subject: | File::Spec should NOT cache $ENV{TMPDIR} |
File::Spec caches $ENV{TMPDIR}; see this code in File/Spec/Unix.pm:
sub tmpdir {
return $tmpdir if defined $tmpdir;
$tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" );
}
This prevents you from being able to change $ENV{TMPDIR} on the fly. Arguably, you shouldn't do that
because you should just invoke File::Temp (which calls File::Spec) with a proper directory argument, but
often you use Perl modules that internally call File::Temp and over which you have no control. It is therefore
desirable not to cache $ENV{TMPDIR}, but to reread it out of the environment every time.
Regards,
David.
sub tmpdir {
return $tmpdir if defined $tmpdir;
$tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" );
}
This prevents you from being able to change $ENV{TMPDIR} on the fly. Arguably, you shouldn't do that
because you should just invoke File::Temp (which calls File::Spec) with a proper directory argument, but
often you use Perl modules that internally call File::Temp and over which you have no control. It is therefore
desirable not to cache $ENV{TMPDIR}, but to reread it out of the environment every time.
Regards,
David.