in reply to Getting logical path from Perl?

Does this do what you want?

$ cat /tmp/foo/mydir.pl #!/usr/bin/env perl use strict; use warnings; use Path::Tiny; my $path = path ($0); my $dir = $path->parent->stringify; print "\$0: $0\n"; print "Path::Tiny: $dir\n"; $ ls -l /tmp/foo lrwxrwxrwx. 1 user users 3 Mar 8 13:47 /tmp/foo -> bar $ /tmp/foo/mydir.pl $0: /tmp/foo/mydir.pl Path::Tiny: /tmp/foo $

🦛

Replies are listed 'Best First'.
Re^2: Getting logical path from Perl?
by mathomp4 (Novice) on Mar 09, 2021 at 13:20 UTC

    Good news, it does what we want. Bad news, it depends on the calling script using the logical path to the script, which might expose the same issue. I'm beginning to think we might just need to rewrite some scripting to be more robust...

    That said, thanks for all the lessons in Perl!