just a small additional point in case you are not bored with cwd yet. and a question for perl command line flag devotees.
imagine i have a script, cwd.pl, whose location is
home/wufnik/scripts, and looks something like:
use Cwd;
print cwd . "\n";
then, as pointed out above, if i run this using:
/home/wufnik/scripts/cwd.pl, sitting in /home/,
/home will be printed as the current working directory.
exactly the same behaviour will be found if you use
the
perl -S cwd.pl
method of script invocation, ie: search through my $PATH,
which naturally contains /home/wufnik/scripts, for cwd.pl.
i also get this behaviour if i try running
perl -e 'print `perl -S cwd.pl`'
from /tmp, where it would print out: /tmp
i would like to know what happens when you use the perl -x flag, which
"switches to that directory before running the program". can't seem to get this to change to any directory on my win32 box, running cygwin, and the -h for perl gives: 'perhaps cd to directory'.
perhaps! is this a case of hubris in perl-the-app? do i have to be especially
good for this cd to take place? is the sense of mystery here designed to lend yet more allure to the perl command line? anyone use this flag before? if so, what does it do to cwd?
any enlightenment, even a wee bit, appreciated greatly...
wufnik
-- in the world of the mules there are no rules --
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.