O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required