September 2002
Intermediate to advanced
544 pages
13h 6m
English
Now let’s look at how files are handled from within Perl programs. Redirection operators are used when files are opened in Perl to indicate how the file will be used. Because CGI programs so often work with external files, it’s important to understand how Perl handles these operations.
To access an external file from within a Perl function, the open function is used. It accepts two arguments, the filehandle that will be used to refer to the file, and the specification for the file to be opened. Here’s an example:
open (FILE, "< this_file.html");
The first argument is FILE. When I want to retrieve data from the file later in the program, I’ll use the filehandle FILE to do so. You don’t have to make your filehandles ...
Read now
Unlock full access