Solved

get current path to current directory.

Posted on 1998-02-13
3
2,449 Views
Last Modified: 2008-02-01
Just want to know how getting current whole path to current directory, changed in my script with chdir for example...
0
Comment
Question by:steph84
3 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 1209757
#!/usr/local/bin/perl

$PATH=`pwd`;
print "$PATH\n";
0
 
LVL 84

Expert Comment

by:ozo
ID: 1209758
Or, if you want to be more portable to different operating systems

use Cwd;
$PATH = cwd();

or, to override chdir to keep PWD up to date

use Cwd 'chdir';
chdir $PATH;
print $ENV{PWD};

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1209759
IMHO, all the built-in things about pwd, cwd, chdir are to be used with extreme care in perl, except you realy know what they are doing.

For example:
  - manipulate the imported environment PWD, usually not what you expect
  - use `pwd` even on platforms where it is not supported (pwd.pl)
Also keep in mind that in a shell $cwd may be differ to `pwd` and both a different to that what  "df ."   reports.

Things go wrong, even with perl :-(
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question