⭐ in reply to How do I get the full path for a file?
Add this to the top of your code:
use Cwd;
Then you can just:
$thisdir = cwd();
This gets the directory the "safest" way. If you are definitely on unix, however, you can simply say:
which is usually what Cwd does on unix systems. It has a few other options, such as fastcwd() and getcwd() but they are not used much. You can grab the name of the script itself by looking in $0 or even __FILE__.$thisdir = `pwd`;
If you are doing it through the web, check out the environment variable 'SCRIPT_FILENAME'
$pwd = $ENV{'SCRIPT_FILENAME'};
|
---|