I have this code to print the current directory using Perl:
use Cwd qw(abs_path);
my $path = abs_path($0);
print \"$path\\n\";
But it is di
I used my script in dirs with symlinks. The script parses the path and executes commands depending on the path. I was faced with the correct determination of the current path.
Here is example:
root@srv apache # pwd
/services/apache
root@srv apache # readlink -f .
/services/apache2225
Cwd module disclosures path (analogue of readlink -f) http://perldoc.perl.org/Cwd.html
root@server apache # perl -e 'use Cwd; print cwd . "\n";'
/services/apache2225
If you need to get current path like pwd, you can use $ENV{'PWD'}
root@srv apache # perl -e 'use Cwd; print $ENV{'PWD'}."\n";'
/services/apache
Thank you.