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

Ken McGlothlen mcglk at serv.net
Fri Sep 3 12:16:20 CDT 1999


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'};
	}

That pretty much sums up the difference:  Win32::GetCwd() returns a directory
in DOS form, with backslashes, whereas the Cwd module will convert those to
forward slashes.

And thanks for reminding me about the Cwd module; I really should use that more
often rather than just backticking pwd.  :)

							---Ken

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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