Input and Output with File Handles

Way back on Day 2, “Working with Strings and Numbers,” you learned just a bit about file handles, as part of the information on standard input and output. At that time, I ex-plained that STDIN and STDOUT are a special kind of file handle that refer to nonfile-based input and output streams—the keyboard and the screen, for example. And, conveniently, much of what you've learned already is going to apply just as well to file handles that refer to actual files.

In this section, you'll learn how to tame the wily file handles: creating them with the open function, reading from them, writing or appending to them, and closing them when you're done. Along the way, we'll review what you've learned so far about input ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition 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.