Other Handy File Commands
-
Note that we have been using the relative path when writing to a file.
For example, the .. in
open(PAGE, ">>../$bearcatID.html");
actually writes this file in the parent directory. Since
we are working in the .www/cgi-bin directory, this would put it in the
.www directory. You can put it in any reasonable directory you like.
-
If you are generating an HTML page to be read by the public, you will want
to change permissions on it. You can do that in the script, with:
chmod (0755, "../mypage.html");
Where chmod is the function to change the permissions, 0755
is the permission you wish to grant, and "../mypage.html" is the
name of the file, in this case, mypage.html in the parent directory.
-
The book is full of additional file and directory functions. For
example:
-
Renaming a file.
-
Removing a file.
-
Checking a file's status (good thing to do before you attempt to read it).
-
Accessing a directory.
-
Reading the contents of a directory.
-
Changing the working directory.
-
Creating a directory
-
The book also has much more on string parsing. This is considered
one of the strengths of Perl.
More About Files
Home