[Tutor] perl

D-Man dsh8290@rit.edu
Tue, 23 Jan 2001 21:31:08 -0500


On Tue, Jan 23, 2001 at 05:13:29PM -0800, Matthias Hager wrote:
| I know this is off the subject of Python, but this is the only place I could think of to come to. But here's a Perl Q or two.
| 1. How can you get the current location of a user in *nix? Where they are at directory wise. And how can you change their location to a different directory? I want to kind of emulate the cd and evrything functions of bash.

Did you make a typo and type "perl" instead of "python" ?  ;-)

import os

print os.getcwd()  # works on all platforms :-)
os.chdir( "/etc" ) # function works on all platforms, but the argument
		   # might give you some sort of invalid path error
print os.getcwd()


Enjoy studying python on a python tutor list.  :-)
-D