Skip to Content
Programming Perl, 3rd Edition
book

Programming Perl, 3rd Edition

by Larry Wall, Tom Christiansen, Jon Orwant
July 2000
Intermediate to advanced
1104 pages
35h 1m
English
O'Reilly Media, Inc.
Content preview from Programming Perl, 3rd Edition

use open

use open IN => ":crlf", OUT => ":raw";

The open pragma declares one or more default disciplines for I/O operations. Any open and readpipe (that is, qx// or backticks) operators found within the lexical scope of this pragma that do not specify their own disciplines will use the declared defaults. Neither open with an explicit set of disciplines, nor sysopen under any cirumstances, is influenced by this pragma.

Only the two disciplines :raw and :crlf are currently available (though as of this writing we expect a :utf8 discipline to be along shortly). On legacy systems that distinguish between those two translation modes when opening files, the :raw discipline corresponds to "binary mode", and :crlf to "text mode". (These two disciplines are currently no-ops on platforms where binmode is a no-op, but only for now; see the open function in Chapter 29, for a longer description of the semantics we expect of various disciplines.)

Full-fledged support for I/O disciplines is currently unimplemented. When they are eventually supported, this pragma will serve as one of the interfaces to declare default disciplines for all I/O. At that time, any default disciplines declared by this pragma will be available by the special discipline name ":DEFAULT" and usable within handle constructors that allow disciplines to be specified. This will make it possible to stack new disciplines over the default ones.

open (FH, "<:para :DEFAULT", $file) or die "can't open $file: $!";

Once complete, full support ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Perl, 4th Edition

Programming Perl, 4th Edition

Tom Christiansen, brian d foy, Larry Wall, Jon Orwant
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Programming the Perl DBI

Programming the Perl DBI

Tim Bunce, Alligator Descartes

Publisher Resources

ISBN: 0596000278Supplemental ContentErrata