develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #26988] EOF character (0x1A) returned as data when readingtext files

Thread Previous | Thread Next
From:
Eric Brine
Date:
May 27, 2013 17:17
Subject:
Re: [perl #26988] EOF character (0x1A) returned as data when readingtext files
Message ID:
CALJW-qGaipjt_AvCEso0picKYwbg1Z1PbOamYuCECVnK1+wi9g@mail.gmail.com
On Mon, May 27, 2013 at 8:55 AM, James E Keenan via RT <
perlbug-followup@perl.org> wrote:

> Is there someone with up-to-date Perl and Windows who could assess the
> issues discussed in this older ticket?
>

Perl still doesn't treat ^Z specially as of 5.16.2 (and no reason to
believe it's any different in 5.18.0).

    >perl -e"print qq{abc\n\cZ\ndef\n}" >file

    >type file
    abc

    >perl -pe1 file
    abc
    →
    def

    >perl -pe1 <file
    abc
    →
    def

Note that using Ctrl-Z to close STDIN (as you would use Ctrl-D in unix)
works fine.

    >perl -pe1
    abc
    abc
    ^Z

I don't think this is a "feature" we need to implement. While I encountered
a couple of text files with a trailing ^Z back in the days of DOS 3, I've
never encountered such a file since. Windows text editors (e.g. notepad) do
not treat ^Z specially. Even C<type> (used above) only obeys it when
writing to a terminal.

    >type file | perl -pe1
    abc
    →
    def

I don't see any reason to implement it other than "some other libraries do"
(including C's stdio).

- Eric

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About