Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

[solved] File::Spec tmpdir() is behaving wrongly in Windows7

by sam_bakki (Pilgrim)
on Jul 31, 2013 at 11:20 UTC ( #1047236=perlquestion: print w/replies, xml ) Need Help??
sam_bakki has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

OS: Windows7
Perl : Active Perl 5.16, x86

C:\>set TMPDIR=C:\Temp C:\>set TEMP=C:\Temp C:\>perl -MFile::Spec -e "print File::Spec->tmpdir();" \ C:\>perl -MFile::Spec -e "print $File::Spec::VERSION;" 3.40

I expect C:\Temp but it is giving \. Am I doing something stupid or do you also face issue with File::Spec?

Thanks & Regards,
Bakkiaraj M
Perl Gtk2 technology demo project - , contributions are welcome.

Replies are listed 'Best First'.
Re: File::Spec tmpdir() is behaving wrongly in Windows7
by sundialsvc4 (Abbot) on Jul 31, 2013 at 13:15 UTC

    A read of the docs in File::Spec::Win32 leads me to this quote:

    Returns a string representation of the first existing directory from the following list:


    I know that Windows environment-variables are defined in a control-panel.   With a little bit of sleuthing through this information, you ought to be able to identify and resolve the problem ... ?

      And a thought for the out-of-box folks: It is possible, under certain environments, that the directory exists but the account running the script might not have sufficient access to see it. It would therefore "not exist" from the runtime perspective.

      Not allowed to ask how I know this can be an issue. :-(

      Hi sundialsvc4

      To avoid confusion, I set the environment variable SET TMPDIR=C:\Temp and then ran the perl code. Still I get the wrong results.
      C:\Temp is avilable with full permission to all users.
      I have created perlApp (Active State based) exe and executed in other machines, I face the same isse with File::Spec.
      What I understand with all the monks post is, it is File::Spec issue. I will reinstall perl freshly and try again.

      Thanks & Regards,
      Bakkiaraj M
      My Perl Gtk2 technology demo project - , contributions are welcome.

        Hi sundialsvc4

        Great. Thanks for your support. Issue is solved. Looks like my C:\Temp was created by system, though it exists with write permission some how perl is not getting permission to work in it. So I have set Temp dir in my local account like below,

        C:\> SET TMPDIR=C:\Users\bakki\AppData\Local\Temp C:\> perl -MFile::Spec -e "print File::Spec->tmpdir();" C:\Users\bakki\AppData\Local\Temp

        Now everything work. Actually, it the default Temp set by windows for every user, I have modified it to point to System temp which is wrong.

        Thanks & Regards,
        Bakkiaraj M
        My Perl Gtk2 technology demo project - , contributions are welcome.

Re: File::Spec tmpdir() is behaving wrongly in Windows7
by ww (Bishop) on Jul 31, 2013 at 12:54 UTC

    Can't reproduce your problem w/Win7 and ActiveState's ...perl 5, version 16, subversion 2 (v5.16.2) built for MSWin32-x86-multi-thread:

    C:\ww>set TMPDIR=C:\Temp C:\C:\ww>set TEMP=C:\Temp C:\ww>>perl -MFile::Spec -e "print File::Spec->tmpdir();" C:\ww\AppData\Local\Temp C:\ww>>perl -MFile::Spec -e "print $File::Spec::VERSION;" 3.39_02
    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.
Re: File::Spec tmpdir() is behaving wrongly in Windows7
by MidLifeXis (Monsignor) on Jul 31, 2013 at 13:33 UTC

    Does C:\Temp exist? The documentation states that tmpdir "Returns a string representation of the first existing [emphasis added] directory..."

    Update: sundialsvc4 got to it first. :-)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1047236]
Approved by Loops
[Corion]: Meh. I think I have now the parts down that I want from a simple Javascript frontend for single-page- applications with a aPerl backend. But it seems that all Javascript templating modules either don't support two-way binding (which would be nice) or ...
[Corion]: ... don't support server-side precompilation (which means the client has to compile all templates to Javascript themselves), or are giant frameworks that expect to do everything (which is not what I want)
[Corion]: I feel that there is a talk somewhere in there, either about the structure and parts, or how I used several parts to get a complete whole.
[Corion]: Maybe I can still find something that is compatible with handlebars.js (which has JS precompilation) but allows for two-way data binding (which is great for the UI)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2017-03-30 07:44 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (355 votes). Check out past polls.