Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Current working directory on win32

by pernod (Chaplain)
on Oct 14, 2004 at 13:31 UTC ( [id://399202]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Current working directory on win32
in thread Current working directory on win32

Ah! I think I see your nuance, although I would argue that it is of a somewhat academic character in this case. Isn't "Locates directory of original perl script" in this case similar to Cwd's "get pathname of current working directory"?

After all, the end results are (on my box) the same. TIMTOWDI, you know ;)

use FindBin; use Win32; use Cwd; my( $path, $filename ) = Win32::GetFullPathName( $0 ); my $longpath = Win32::GetFullPathName( $path ); print "FindBin: $FindBin::Bin\n"; print "Win32: $longpath\n"; print "Cwd: ", cwd(), "\n";

The result:

c:/dev/temp/monks $ perl wdir.pl FindBin: C:/dev/temp/monks Win32: c:\dev\temp\monks\ Cwd: c:/dev/temp/monks

Seems to me that FindBin and Cwd does more or less the same job here?

pernod
--
Mischief. Mayhem. Soap.

Replies are listed 'Best First'.
Re^4: Current working directory on win32
by Limbic~Region (Chancellor) on Oct 14, 2004 at 13:58 UTC
    pernod,
    Notice kamesh3183 said the command prompt and didn't indicate if it was in the same directory. Win32 aside, see the difference:
    $ cat /tmp/foo.pl #!/usr/bin/perl use strict; use warnings; use FindBin; use Cwd; print "FindBin: $FindBin::Bin\n"; print "Cwd: ", cwd(), "\n"; $ ./tmp/foo.pl FindBin: /tmp Cwd: /

    Cheers - L~R

Re^4: Current working directory on win32
by vjo (Novice) on Oct 15, 2004 at 17:08 UTC
    > Seems to me that FindBin and Cwd does more or less the same job here?

    No

    c:/ $ perl temp/wdir.pl
    FindBin: C:/temp
    Win32:   C:\temp\
    Cwd:     C:/
    c:/ $ 
    
    Whether he should use FindBin or getcwd depends on what he is trying to achieve.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://399202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found