Solved

get current path to current directory.

Posted on 1998-02-13
3
2,452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
Six Sigma Control Plans

626 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