Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you determine current directory? Newbie question

Status
Not open for further replies.

rmtsmith

MIS
Apr 3, 2002
15
US
I am a newbie and I can not find a method for determining what drive and directory my perl script is running from. I am running in Win2K and will be sharing the directory so the drive designation will change.
 
Yes - that helps but in Windows, it returns the wrong slant-
n:\scripts
rather than
n:/scripts

is there a way to get it correctly for windows?
 
Actually, in perl (even in windows), you can use either (keeps from having double slashes everywhere). If you're storing them to use elsewhere, you can use a short regex to swap them:
Code:
$current_working_directory = cwd();
$current_working_directory =~ tr/\//\\/;
print $current_working_directory;

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top