|Perl: the Markov chain saw|
Re: Re^3: Find the full path of the script at run timeby ibanix (Hermit)
|on Mar 13, 2003 at 00:29 UTC||Need Help??|
Welp, I tried
and it works. It returns the exact same thing, in this one specific case, as plain $0.
First, thanks for all the help! :-)
Second, the decision. I have a bunch of scripts to convert. They will all be shared on a network drive and our team will run them over the network. I need the path so I can determine where the config files for the scripts are, on the fly, even if the whole set of scripts move to another location. This setup will let us always stay in-sync and share scripts, etc.
Is it going to be worthwhile for me to put in the full-blown use File::Spec::Functions qw(rel2abs);, or can I get away with just $0? This is a judgement call, but I want your judgements! :-)
After some experimentation, I've decided to go with the following for finding the directory my scripts are running in.
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;