in reply to Re: Determining directory where script was called from
in thread Determining directory where script was called from
Hello nysus,
Glad $ENV{PWD} is working for you, but it doesn’t work for me on Windows:
15:51 >perl -wE "say $ENV{PWD};" Use of uninitialized value in say at -e line 1. 15:51 >
On the other hand, Cwd::getcwd() [or Cwd::cwd()] works fine for me, and is a more portable solution.
I tried using `getcwd()` to get the current working directory where the script was called from but it is returning undefined.
Was your call to the remote script something like this?
printf "\n%s\n", `perl remote_dir/remote_script.pl`;
If so, you’ll get undefined because backticks in list context returns a list (of lines; see perlop#Quote-Like-Operators). In scalar context it works as expected:
printf "\n%s\n", scalar `perl 1984_SoPW/remote.pl`;
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|