man PerlIO::eol () - PerlIO layer for normalizing line endings

NAME

PerlIO::eol - PerlIO layer for normalizing line endings

VERSION

This document describes version 0.13 of PerlIO::eol, released October 18, 2004.

SYNOPSIS

    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" );

DESCRIPTION

This layer normalizes any of CWCR, CWLF, CWCRLF and CWNative into the designated line ending. It works for both input and output handles.

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

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

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

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

The CWCR, CWLF, <CRLF> and <NATIVE> constants are also exported at request.

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

Inspired by PerlIO::nline by Ben Morrow, <PerlIO-eol@morrow.me.uk>.

COPYRIGHT

Copyright 2004 by Autrijus Tang <autrijus@autrijus.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>