in reply to Write file using full path returns error

First of all, you didn't say so, but it sounds like you're writing a CGI program, right?

Why would I be getting the error with the absolute? What incredibly elementary thing am I missing?

You sound like you're confusing URLs with UNIX file paths. An "absolute" URL identifies the service and the host, such as "http://www.perlmonks.com". A relative url references another web page, relative to the current web page.

An absolute UNIX filename specifies the exact location of the file: the list of subdirectories you must go through to find the file, starting from the root directory. Absolute unix pathnames start with a "/", such as "/etc/passwd".

When writing CGI scripts, you often deal with both: you write to UNIX files, and you print out links to web pages for browers to follow.

The reason the first example works is because UNIX pathnames, as well as URLs, both share the same way of writing "one level up": by writing a ".." in front of the path to follow.

The reasons the second doesn't is because you're not asking for an absolute UNIX pathname (which is what perl deals with), you're asking for an odd looking relative pathname. Specificly, you've told Perl something like: "from the current directory (because there's no '/' at the start", go to directory "http:", then to the directory "www.domain.com", then to the directory "WysiwygPro", and then create the file "content.txt".

The directories "http:", and "www.domain.com" probably don't exist. If you really want to use the full pathname of the UNIX directory your web server is using, you'll have to look it up: but I don't know why you'ld want it.

Both relative links and relative pathnames are often prefered in both cgi scripts and in HTML, because you can move the cgi script and files without changing all the absolute references.

Hope this helps clear up some of the confusion.

--
AC

  • Comment on Re: Write file using full path returns error