5. Files and Filehandles

It’s easy to work with files in Perl. Its heritage includes some of the most powerful utilities for processing data, so it has the tools it needs to examine the files that contain those data and to easily read the data and write them again.

Perl’s strength goes beyond mere files, though. You probably think of files as things on your disk with nice icons. However, Perl can apply its file-handle interface to almost anything. You can use the filehandle interface to do most of the heavy lifting for you. You can also store filehandles in scalar variables, and select which one you want to use later.

Item 51. Don’t ignore the file test operators

One of the more frequently heard questions from newly minted Perl programmers ...

Get Effective Perl Programming: Ways to Write Better, More Idiomatic Perl, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.