[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] the directory where the script is running




Vicki Brown wrote:

> > And seems to yield reasonable results on other platforms as well.
> 
> Of course it does, and a nice bit of code too, if you want to determine the
> current working directory. But that's not what we want to do... we want to
> determine "the directory where the script is running" and we want to do it
> portably.
> 
> The question was not "where am I?" but rather "where is the script?" The
> answers are likely to differ.

Indeed, thanks for the clarification.  I thought there was also a need 
to keep track of things during chdir()s - though perhaps I missed something 
there too(?).  I think the code that Chris Nandor posted with the use of 
File::Basename and $0 will cover most unices, even those that store only 
basenames in things like $0 under perl.

I note too that according to a CGI RFC at:

   http://Web.Golux.Com/coar/cgi/cgi-120-00a.html

there could be a SCRIPT_NAME, and perhaps a PATH_INFO, and PATH_TRANSLATED, 
in the environment though there does not appear to be any requirement to have 
these -- which are subject to the caveats mentioned like:

  Here they are shown using a canonical representation of capitals plus 
  underscore ("_"). The actual representation of the names is system 
  defined; for a particular system the representation may be defined 
  differently than this. .

as well as:

  The algorithm the server uses to derive PATH_TRANSLATED is obviously 
  implementation defined; CGI scripts which use this variable may suffer 
  limited portability. 

HTH.

Peter Prymmer



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org