O'Reilly logo

A Practical Guide to Linux® Commands, Editors, and Shell Programming, Third Edition by Mark G. Sobell

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

Working with Files

Opening a file and assigning a handle

A handle is a name you can use in a Perl program to refer to a file or process that is open for reading and/or writing. When you are working with the shell, handles are referred to as file descriptors (page 452). As when you are working with the shell, the kernel automatically opens handles for standard input (page 133), standard output (page 133), and standard error (page 282) before it runs a program. The kernel closes these descriptors after a program finishes running. The names for these handles are STDIN, STDOUT, and STDERR, respectively. You must manually open handles to read from or write to other files or processes. The syntax of an open statement is

open (file-handle, ['mode

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