Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get current path to current directory.

Posted on 1998-02-13
3
Medium Priority
?
2,454 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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

722 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