Mark,

It may also help to use the File::Spec modules for building paths - it allows for 
greater portability.

-Charles
 Euonymic Solutions
 [EMAIL PROTECTED]

At 12:27 PM -0700 10/22/2002, Mark Wheeler wrote:
>Thank you all for your help. For some reason the ":" instead of "/" didn't
>click, but I remember reading that, now. And, yes, I mistakenly sent this
>post to the wrong list. Thanks for the heads up.
>
>Mark Wheeler
>
>----- Original Message -----
>From: "Thomas Wegner" <[EMAIL PROTECTED]>
>To: "Mark Wheeler" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>Sent: Tuesday, October 22, 2002 1:08 AM
>Subject: Re: [MacPerl-Modules] writing file in wrong directory
>
>
>> At 23:02 Uhr -0700 21.10.2002, Mark Wheeler wrote:
>> >Hi all,
>> >
>> >Here is a quick one that confuses me. I am trying to open one file in the
>> >cgi-bin directory, modify it's contents, then write the altered file to a
>> >completely different directory (up one directory, then into another
>> >directory). Here is the script:
>> >
>> >----------------------------
>> >
>> >
>> >sub createpage {
>> >
>> >open (GETFILE, "<$pathtotemplatepage") ||die " $!";   # open .html
>template
>> >@contents=<GETFILE>;   # read contents into array
>> >$linenum=0;
>> >close (GETFILE);
>> >$lastline=$#contents;
>> >for ($last=0; $last<$lastline+1; $last=$last+1) {
>> >                 $contents[$last]=~s/:username:/$username/; #change
>contents
>> >         }
>> >open (WRITEPAGE, ">../clients/client1.html");  # write file to new
>directory
>> >print WRITEPAGE @contents;
>> >close (WRITEPAGE);
>> >
>> >}
>> >
>> >
>> >----------------------------
>> >
>> >Here is what I get. The original file (the .html template) is read fine,
>> >altered fine, and written fine, except for two things which I think are
>> >connected. The final file that is written, is written to the cgi-bin
>> >directory (where the script is run), not the "clients" directory AND, the
>> >name of the file is not "client1.html", but rather
>"../clients/client1.html"
>> >
>> >What am I missing? Any help would be appreciated.
>> >
>> >Mark
>>
>>
>> You are on Mac OS Classic, right? So, one directory up and then down
>> into the 'clients' directory would be
>>
>>    "::clients:client1.html"
>>
>>
>> Here's a brief reminder of the Mac OS Classic path specification rules:
>>
>> The path separator is a colon ':', not a slash '/'. A full path
>> always begins with a volume name. A relative pathname on Mac OS
>> Classic must always begin with a ':', except when specifying a file
>> or directory name in the current working directory, where the leading
>> colon is optional. If specifying a volume name only, a trailing ':'
>> is required (otherwise its optional, but should be used to
>> distinguish file from directory paths).
>>
>> The current directory is denoted by ':',  one directory up would be
>> '::', two directories up would be ':::' and so on.
>>
>>
>> Btw,  this list is for discussion about modules, not general (Mac-)
>> Perl questions. So your question is better suited for the
>> <[EMAIL PROTECTED]> mailing list (or maybe the
>> <[EMAIL PROTECTED]> list).
>>
>> HTH,
>>
>> Thomas.


Reply via email to