Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 71799
Status: resolved
Priority: 0/
Queue: CGI

Owner: Nobody in particular
Requestors: jeff [...]

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)

Subject: find_tempdir() still has problems under ms-windows
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1493
Download (untitled) / with headers
text/plain 1.4k
Older versions had the following code in the find_tempdir sub: if( $CGI::OS eq 'WINDOWS' ){ unshift @TEMP, $ENV{TEMP}, $ENV{TMP}, $ENV{WINDIR} . $SL . 'TEMP'; } This was problematic because it could put 'undef' values onto the @TEMP array. This is fixed in 3.55 (and before) via the following: # PeterH: These vars may not exist if this is invoked... unshift(@TEMP,$ENV{TEMP}) if defined $ENV{TEMP}; unshift(@TEMP,$ENV{TMP}) if defined $ENV{TMP}; unshift(@TEMP,$ENV{WINDIR} . $SL . 'TEMP') if defined $ENV{WINDIR}; HOWEVER, this new code puts entries onto @TEMP in the opposite order of the original code. The result is that C:\WINDOWS\TEMP will be preferred over the settings from the environment variables, which is *not* what most people will want. The order of the above three lines should be reversed: unshift(@TEMP,$ENV{WINDIR} . $SL . 'TEMP') if defined $ENV{WINDIR}; unshift(@TEMP,$ENV{TMP}) if defined $ENV{TMP}; unshift(@TEMP,$ENV{TEMP}) if defined $ENV{TEMP}; ----- An alternative fix would be to restore the old code and remove the other 'if defined' check that appears, and then change the line inside the loop: for (@TEMP) { do {$TMPDIRECTORY = $_; last} if -d $_ && -w _; } to do {$TMPDIRECTORY = $_; last} if defined($_) && -d $_ && -w _; Thanks! -Jeff PS: Yes, I am kind of ashamed of myself for using Perl with ms-win, but I have no choice, I tellya, they've got my kids and won't release them unless I cooperate !-)
From mark [...] Thu Oct 27 09: 42:27 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-6.581 tagged_above=-99.9 required=10 tests=[AWL=-0.346, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_SOFTFAIL=0.665] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-2600-1319076913-1811.71799-4-0 [...]>
X-Spam-Flag: NO
References: <RT-Ticket-71799 [...]> <rt-3.8.HEAD-2600-1319076913-1811.71799-4-0 [...]>
X-Virus-Scanned: Debian amavisd-new at
Message-ID: <4EA95FB4.3030704 [...]>
Content-Type: text/plain; charset=UTF-8
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.581
Received: from localhost (localhost []) by (Postfix) with ESMTP id BC75E240BE9 for < [...]>; Thu, 27 Oct 2011 09:42:27 -0400 (EDT)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id vTucqq1M5Ur1 for < [...]>; Thu, 27 Oct 2011 09:42:26 -0400 (EDT)
Received: from ( []) by (Postfix) with SMTP id 33176240AFF for < [...]>; Thu, 27 Oct 2011 09:42:26 -0400 (EDT)
Received: (qmail 538 invoked by uid 103); 27 Oct 2011 13:42:25 -0000
Received: from ( by with QMQP; 27 Oct 2011 13:42:25 -0000
Received: from (HELO ( by (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Thu, 27 Oct 2011 06:42:23 -0700
Received: (qmail 30992 invoked from network); 27 Oct 2011 13:42:18 -0000
Received: from ( by with SMTP; 27 Oct 2011 13:42:18 -0000
Delivered-To: [...]
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
Subject: Re: [ #71799] find_tempdir() still has problems under ms-windows
Return-Path: <mark [...]>
X-Original-To: [...]
Date: Thu, 27 Oct 2011 09:42:12 -0400
To: [...]
Content-Transfer-Encoding: 7bit
From: Mark Stosberg <mark [...]>
RT-Message-ID: <rt-3.8.HEAD-2600-1319722948-103.71799-0-0 [...]>
Content-Length: 253
Download (untitled) / with headers
text/plain 253b
Thanks for the report, Jeff. Either option proposed seems fine. If you want to make this really easy for me, you could fork on github and submit a pull request. But, the change is simple enough. Someone will take a look and merge it. Thanks again.
X-RT-Interface: REST
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
RT-Message-ID: <rt-4.0.18-5432-1400760742-1464.71799-0-0 [...]>
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 240
Download (untitled) / with headers
text/plain 240b
This issue has been copied to: please take all future correspondence there. This ticket will remain open but please do not reply here. This ticket will be closed when the github issue is dealt with.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2643-1405087201-91.71799-0-0 [...]>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 552
Download (untitled) / with headers
text/plain 552b
commit cb434b3b27897e2a486c930f144bba60216caa22 Author: Lee Johnson <> Date: Fri Jul 11 15:56:35 2014 +0200 resolve #91 [ #71799] - WIN TEMP dir order returned to that before e24d04e9bc5fda7722444b02fec135d8cc2ff488, which fixed issues with undefined values being unshifted onto the array. However the change from a single unshift statement to three calls mean the order was changed. restore the original order by reversing the order of the unshift calls Changes | 4 ++++ lib/ | 4 ++--

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to