1PerlIO::eol(3)        User Contributed Perl Documentation       PerlIO::eol(3)
2
3
4

NAME

6       PerlIO::eol - PerlIO layer for normalizing line endings
7

VERSION

9       This document describes version 0.18 of PerlIO::eol, released December
10       18, 2006.
11

SYNOPSIS

13           binmode STDIN, ":raw:eol(LF)";
14           binmode STDOUT, ":raw:eol(CRLF)";
15           open FH, "+<:raw:eol(LF-Native)", "file";
16
17           binmode STDOUT, ":raw:eol(CRLF?)"; # warns on mixed newlines
18           binmode STDOUT, ":raw:eol(CRLF!)"; # dies on mixed newlines
19
20           use PerlIO::eol qw( eol_is_mixed );
21           my $pos = eol_is_mixed( "mixed\nstring\r" );
22

DESCRIPTION

24       This layer normalizes any of "CR", "LF", "CRLF" and "Native" into the
25       designated line ending.  It works for both input and output handles.
26
27       If you specify two different line endings joined by a "-", it will use
28       the first one for reading and the second one for writing.  For example,
29       the "LF-CRLF" encoding means that all input should be normalized to
30       "LF", and all output should be normalized to "CRLF".
31
32       By default, data with mixed newlines are normalized silently.  Append a
33       "!"  to the line ending will raise a fatal exception when mixed
34       newlines are spotted.  Append a "?" will raise a warning instead.
35
36       It is advised to pop any potential ":crlf" or encoding layers before
37       this layer; this is usually done using a ":raw" prefix.
38
39       This module also optionally exports a "eol_is_mixed" function; it takes
40       a string and returns the position of the first inconsistent line ending
41       found in that string, or 0 if the line endings are consistent.
42
43       The "CR", "LF", "CRLF" and "NATIVE" constants are also exported at
44       request.
45

EXPORTS

47   CR
48       A carriage return constant.
49
50   CRLF
51       A carriage return/line feed constant.
52
53   LF
54       A line feed constant.
55
56   NATIVE
57       The native line ending.
58
59   eol_is_mixed
60       This module also optionally exports a "eol_is_mixed" function; it takes
61       a string and returns the position of the first inconsistent line ending
62       found in that string, or 0 if the line endings are consistent.
63

AUTHORS

65       Audrey Tang <autrijus@autrijus.org>.
66
67       Janitorial help by Gaal Yahas <gaal@forum2.org>.
68
69       Inspired by PerlIO::nline by Ben Morrow, <PerlIO-eol@morrow.me.uk>.
70
72       Copyright 2004-2006 by Audrey Tang <audreyt@audreyt.org>.
73
74       This program is free software; you can redistribute it and/or modify it
75       under the same terms as Perl itself.
76
77       See <http://www.perl.com/perl/misc/Artistic.html>
78
79
80
81perl v5.36.1                      2023-07-10                    PerlIO::eol(3)
Impressum