Solved

get current path to current directory.

Posted on 1998-02-13
3
2,445 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
Comment Utility
#!/usr/local/bin/perl

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

Expert Comment

by:ozo
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now