Perl Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 5.00

File Handles and Data Input/Output

This chapter provides tutorial examples and notes about file handles and data input or output. Topics include using open() function to open file handles; using print() to output data; using <file_handle> to input data.

open() - Opening File Handles for Input and Output

print() - Printing Output to File Handles

<file_handle> - Reading Data from File Handles

Conclusions:

  • open(IN, "< $file"); - Opening a file handler to a file for data input.
  • <IN> - Reading one record or all records from a file handler.
  • open(OUT, "> $file"); - Opening a file handler to a file for data output.
  • print OUT @list; - Printing a list of values to a file handler.

Dr. Herong Yang, updated in 2008
File Handles and Data Input/Output