There are a number of modules that return an absolute path without resolving anything.
use Path::Tiny qw( path ); my $abs = path($0)->absolute;
For example, launching the script using ./a.pl or perl a.pl from /home/ikegami/foo would result in /home/ikegami/foo/a.pl.
But note that launching the script using ../bar/a.pl or perl ../bar/a.pl from /home/ikegami/foo would result in /home/ikegami/foo/../bar/a.pl. That's because /home/ikegami/foo/../bar/a.pl can't be safely reduced to /home/ikegami/bar/a.pl because /home/ikegami/foo might be a symlink.
Seeking work! You can reach me at ikegami@adaelis.com
In reply to Re: Getting the absolute path of a script, without PWD
by ikegami
in thread Getting the shell's version of working directory, without PWD's help
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |