in reply to How is the default "Input Record Separator" set?

Thanks for the responses - and I did do extensive searching (i.e. that's what I found when searching - that perl should never see the CR). However, I'm seeing something different (running as "perl cmds.pl" in a Command Prompt on Windows 10)

File 'cmds.pl':

open my $makefileToProcess, "<", "input_file.txt" or die "input_file.t +xt: $!"; while (my $line = <$makefileToProcess>) { print "LINE BEFORE:$line:\n"; chomp $line; print "LINE AFTER:$line:\n"; }
And what I see is:
LINE BEFORE:xyzCRLF: LINE AFTER:xyzCR:

(NOTE that CRLF is the CRLF pair, not actual 'C''R'L'F'. Same with CR.)

What's even more interesting is if, instead of running as "perl cmds.pl", I use the Windows ".pl" association, and run simply as "perl_cmds.pl", it works as you described (i.e. the CR is never seen).

In this case, I have 2 different perl implementations installed, one being cygwin (perl version 5.26, which is the one that keeps the CR) and the other being a standalone perl (perl v5.8.8, which is the one that eliminates the CR).

This is why I originally asked how the default IRS gets set, but perhaps the real question is why one perl on a Windows system is allowing the CR to pass through to the perl script.

Replies are listed 'Best First'.
Re^2: How is the default "Input Record Separator" set?
by haukex (Archbishop) on Mar 15, 2021 at 18:56 UTC
    In this case, I have 2 different perl implementations installed, one being cygwin (perl version 5.26, which is the one that keeps the CR) and the other being a standalone perl (perl v5.8.8, which is the one that eliminates the CR).

    It's been a while since I worked with cygwin, but I assume that it's acting like a *NIX system would and not loading the :crlf layer by default - try perl -le "print for PerlIO::get_layers(*STDIN)" at the command line to check.

    Note that you can be really explicit about the fact that you want the :crlf layer to be loaded: try and see if open my $makefileToProcess, "<:raw:crlf", ... makes it work on both Perls.

    Also note that 5.8.8 is now over 15 years old. You probably want to consider upgrading, see Strawberry Perl.