SPUG: Win32, use Cwd, and $ENV{PWD}

Stuart Poulin stuart_poulin at yahoo.com
Fri Sep 3 17:14:33 CDT 1999



--- Ken McGlothlen <mcglk at serv.net> wrote:
> jshaffer at chronology.com (Jamie Shaffer) writes:
> 
> | What's the difference between using Cwd to get the getCwd() function and
> | using Win32?
> 
> Well, not much if you're on Win32.  If portability is your concern, then
> 
> 	use Cwd;
> 
> is definitely what you want.  If you look at the Cwd.pm module, you'll find
> the
> following tidbit:
> 
> 	sub _win32_cwd {
> 	    $ENV{'PWD'} = Win32::GetCwd();
> 	    $ENV{'PWD'} =~ s:\\:/:g ;
> 	    return $ENV{'PWD'};
> 	}
> 
...

Just don't rely on $ENV{PWD}, Cwd::chdir() does weird things with it on Win32:

#!perl -l

use Cwd qw(cwd chdir);

chdir ('\\\\achilles\\Perl') or die "Can't cd: $! ";
print "$ENV{PWD}";
print cwd;
print "$ENV{PWD}";

__END__

D:/users/spoulin/tmp/\\achilles\Perl
//achilles/Perl
//achilles/Perl


__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list