Chapter 10. Getting a Handle on Files
Now it is time to see how Perl interacts with files, pipes, and command-line arguments. By the time you have finished this chapter, you should be able to explain the following script.
use feature 'say';die "Insufficient arguments" if scalar @ARGV < 1;while(<>){ say "$ARGV $. $_ "; say "x" x 30 && close ARGV if eof;}
10.1 The User-Defined Filehandle
If you are processing text, you will regularly be opening, closing, reading from, and writing to files. In Perl, we use filehandles to get access to system files.
A filehandle is a name for a file, device, pipe, or socket. In ...
Get Perl by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.