in reply to Re: Re: Find the full path of the script at run time
in thread Find the full path of the script at run time
Anyway, to answer your question: yes, $0 would be set to ..\..\script.pl. That's where tye's solution, rel2abs, would again come to the rescue. A demo of a full solution, as tye merely mentioned the function name:
use File::Spec::Functions 'rel2abs'; print rel2abs($0);
update: Oh dear, it doesn't. The double dots are still in the created path. For Unix, that is the safest, as you never know which "directory" is actually just a link to another directory, so by following "foo/.." you could end up in an entirely different directory from where you started from.
It doesn't look as neat, but it works just as well.
|
|---|