My limited experience and brief experiments suggest that at least on LINUX, the default working directory is always the directory the Perl script is in
Givein a file: /home/me/test.txt and a script: /home/me/wd.pl
#!/usr/bin/perl -w use strict; use Cwd; print "cwd() is:\t\t",cwd(),"\n"; print "should be:\t\t/home/me/\n\n"; print "\$ENV{PWD} is:\t\t",$ENV{PWD},"\n"; print "should be: \t\t/home/me/\n\n"; print '`pwd` is:',"\t\t",`pwd`; print "should be:\t\t/home/me/\n\n"; # both work fine open(FH,'<','test.txt') or die "$!\n"; open(FH,'<','/home/me/test.txt') or die "$!\n";
... everything works as I expect. whether I call ./wd.pl or /home/me/wd.pl
However, my searches here and on perldoc.com using google and super search have not found official confirmation of this (apparent) fact.
Clues?
In reply to current working dir is location of script? by mandog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |