On Sun, 04 Apr 2004 12:18:09 -0700, Joe Cosby
<jo******@SPAMBLOCKmindspring.com> wrote:
This seems like a simple thing, but I can't find anything in the "Perl
Cookbook" or the online Perl docs to answer this.
When a script runs from my host's server, the working directory
doesn't appear to be the directory the script is located in. (They
have Perl running under IIS, I don't know what versions).
I tried File::Spec->curdir() , but it just returns ".", which is
accurate, but not very helpful.
Does anyone know a way to do this?
Maybe I should clarify what I'm trying to accomplish a little.
I want to be have a relative directory structure within my code. For
instance, within a "code" directoy I have scripts, then a subdirectory
"templates" within "code" contains html templates.
I want to be able to read the templates by loading a file
"templates/templatename.htm", instead of having to hard-code
"e:\www\joecosby\code\templates\templatename.h tm" (the path on the
server) in the code I upload, ""C:\My
Documents\webpage\newstuff\code\templates\template name.htm" (the path
on my local machine) in the code before I upload it, etc.
I mean it's the same idea as using relative references versus absolute
references in HTML, it saves me from a huge amount of maintenance
work.
The perl environment seems to know what directory my script is running
from, when I get error messages they include the complete path to the
script, so if I could just chdir() to that directory at the start of
all my scripts that would at least be a workable solution.
--
Joe Cosby
http://joecosby.com/
"Now that I've inspired a character in a Godzilla movie, all I
really still desire is for several Ingmar Bergman characters to sit in a
circle and read my reviews to one another in hushed tones." - Roger Ebert