PerlIO::eol(3pm)

PerlIO::eol3pm

Perlio layer for normalizing line endings

Usage

    binmode STDIN, ":raw:eol(LF)";
    binmode STDOUT, ":raw:eol(CRLF)";
    open FH, "+<:raw:eol(LF-Native)", "file";
    binmode STDOUT, ":raw:eol(CRLF?)"; # warns on mixed newlines
    binmode STDOUT, ":raw:eol(CRLF!)"; # dies on mixed newlines
    use PerlIO::eol qw( eol_is_mixed );
    my $pos = eol_is_mixed( "mixed\nstring\r" );

Version

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

Overview

This layer normalizes any of "CR", "LF", "CRLF" and "Native" into the designated line ending. It works for both input and output handles.

If you specify two different line endings joined by a "-", it will use the first one for reading and the second one for writing. For example, the "LF-CRLF" encoding means that all input should be normalized to "LF", and all output should be normalized to "CRLF".

By default, data with mixed newlines are normalized silently. Append a "!" to the line ending will raise a fatal exception when mixed newlines are spotted. Append a "?" will raise a warning instead.

It is advised to pop any potential ":crlf" or encoding layers before this layer; this is usually done using a ":raw" prefix.

This module also optionally exports a "eol_is_mixed" function; it takes a string and returns the position of the first inconsistent line ending found in that string, or 0 if the line endings are consistent.

The "CR", "LF", "CRLF" and "NATIVE" constants are also exported at request.

Exports

CR

A carriage return constant.

CRLF

A carriage return/line feed constant.

LF

A line feed constant.

Native

The native line ending.

eol_is_mixed

This module also optionally exports a "eol_is_mixed" function; it takes a string and returns the position of the first inconsistent line ending found in that string, or 0 if the line endings are consistent.

Releases

11 releases since Debian 3.1 (Sarge); the text changed 8 times.

  1. 3.1–4.0
  2. 5.0–6.0
  3. 7
  4. 8
  5. 9
  6. 10
  7. 11
  8. 12
  9. 13

Authors

Audrey Tang <[email protected]>.

Janitorial help by Gaal Yahas <[email protected]>.

Inspired by PerlIO::nline by Ben Morrow, <[email protected]>.

From libperlio-eol-perl 0.19-1+b3 in Debian 13 (Trixie). Parsed by carta from the page's man source.