1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!perl -T use strict; use warnings; use File::Temp (); my $tempdir = File::Temp->newdir; print "Tempdir is $tempdir"; =pod generates something like: Tempdir is \2n_ZnUbENO but should be something like: Tempdir is C:\Users\MYNAM~1\AppData\Local\Temp\58nDhHDTcd =cut
QuoteSince Perl 5.8.0, if running under taint mode, and if the environment
variables are tainted, they are not used.
=cut
my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
$tmpdir = $_[0]->_tmpdir( map( $ENV{$_}, qw(TMPDIR TEMP TMP) ),
'SYS:/temp',
'C:\system\temp',
'C:/temp',
'/tmp',
'/' );
}
Quotetmpdir
Returns a string representation of the first existing directory from the following list:$ENV{TMPDIR}
$ENV{TEMP}
$ENV{TMP}
SYS:/temp
C:\system\temp
C:/temp
/tmp
/
The SYS:/temp is preferred in Novell NetWare and the C:\system\temp for Symbian (the File::Spec::Win32 is used also for those platforms).
If running under taint mode, and if the environment variables are tainted, they are not used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
sub tmpdir { my $tmpdir = $_[0]->_cached_tmpdir(qw(TMPDIR TEMP TMP)); return $tmpdir if defined $tmpdir; my $appdata_local_temp; eval{ require Win32; $appdata_local_temp = _canon_cat(Win32::GetFolderPath(Win32::CSIDL_LOCAL_APPDATA()),'Temp'); }; $tmpdir = $_[0]->_tmpdir( map( $ENV{$_}, qw(TMPDIR TEMP TMP) ), $appdata_local_temp, 'SYS:/temp', 'C:\system\temp', 'C:/temp', '/tmp', '/' ); $_[0]->_cache_tmpdir($tmpdir, qw(TMPDIR TEMP TMP)); }