Приглашаем посетить
Булгарин (bulgarin.lit-info.ru)

Hour 5. Working with Files

Previous Table of Contents Next

Hour 5. Working with Files

What You'll Learn in This Hour:

  • How to open and close files

  • How to write data to files

  • How to read data from files

  • How to write Perl defensively so that your programs are robust

Until now, your Perl programs have been self-contained. They have been unable to communicate with the outside world other than to provide messages to the user and receive input from the keyboard. All of that is about to change.

Perl is an outstanding language for reading from and writing to files on disk or elsewhere. Perl's scalars can stretch to hold the longest possible record in a file, and Perl's arrays can stretch to hold the entire contents of files—as long as enough memory is available, of course. When the data is contained within Perl's scalars and arrays, you can perform endless manipulations on that data and write new files.

Perl tries very hard not to get in your way while reading or writing files. In some places, Perl's built-in statements are even optimized for performing common types of file input/output (I/O) operations.

In this hour, you will learn how Perl can give you access to all the data available to you in files.

    Previous Table of Contents Next