Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This works for me on a Mac (Mac OS X 10.7.5, Perl 5.16.2):</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; while (&lt;&gt;) { print "1: [$_]\n"; { local $/ = "\r\n"; chomp; } print "2: [$_]\n"; } </code></pre> <p>Sample output:</p> <pre><code>$ odx x3.txt 0x0000: 6F 6E 69 6F 6E 0D 0A 73 74 61 74 65 0D 0A 6D 69 onion..state..mi 0x0010: 73 68 6D 61 73 68 0D 0A shmash.. 0x0018: $ perl x3.pl &lt; x3.txt | vis -c 1: [onion^M ] 2: [onion] 1: [state^M ] 2: [state] 1: [mishmash^M ] 2: [mishmash] $ </code></pre> <p>The <code>odx</code> program gives me a hex dump of the data file; you can see that there are 0D 0A (CRLF) line endings. The <code>vis -c</code> program shows control characters (other than newline and tab) as <code>^M</code> (for example). You can see that the raw input includes the <code>^M</code> (lines starting <code>1:</code>) but the <code>chomp</code>'d lines are missing both the newline and the carriage return.</p> <p>The only issue will be whether the input on Windows is a text file or a binary file. If it is a text file, the I/O system should do the CRLF mapping automatically. If it is a binary file, it won't. (Unix doesn't have a meaningful distinction between text and binary files.) On Windows, you may need to investigate <a href="http://perldoc.perl.org/functions/binmode.html" rel="nofollow"><code>binmode</code></a>, as discussed on the <a href="http://perldoc.perl.org/functions/open.html" rel="nofollow"><code>open</code></a> page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload