I don't know the history of this thread, but a Windows perl will use the 
`:crlf` layer which is fine for both Windows (CR LF) and Linux (LF) line 
terminations. The CR will be removed, and every line read will end with LF 

The most common problem arises when a Linux perl attempts to read a Windows 
text file. The default PerlIO stack on Linux is an empty one, so the CR LF 
characters appear intact in every line read

There are a few solutions:

1/ Change the default PerlIO layers

    use open qw/ :std :crlf /

will cause every file to be opened with the Windows `:crlf` layer, which 
removes any CR if it is there. It doesn't affect Linux files at all

2/ If you *always* `chomp` every line, then use


instead, which will remove any line termination character or character pair

3/ If you *always* `split` every line using the default of `split ' ', $_` then 
there is nothing to do: CR is considered to be a whitespace character and will 
be removed from the fields

There are clearly variations on this idea, but it shouldn't be hard to resolve 
from here

Can someone please tell me whether I have answered the original question, or if 
I'm miles off?

Rob Dixon

-----Original Message-----
From: Ralph Corderoy <ra...@inputplus.co.uk>
To: get_iplayer@lists.infradead.org
Sent: Tue, 06 Mar 2018 13:30
Subject: Re: Format of options file

Hi David,

> binmode does still work AFAIK, but a more modern and flexible method
> is to use the crlf I/O layer, which is documented here:
>   https://perldoc.perl.org/PerlIO.html
> Note however that an awful lot of perl code just doesn't bother.

Windows stacks the `:crlf' layer by default.  I *think* Richard's trying
to avoid that because he wants his get_iplayer to use POSIX text files
on Linux, as normal, and Windows.

Cheers, Ralph.

get_iplayer mailing list

get_iplayer mailing list

Reply via email to