O'Reilly logo

Sams Teach Yourself CGI in 24 Hours, Second Edition by Rafe Colburn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with Files in Perl

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required