The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
chomp removes the contents of $/ from the end of the string (if present), and $/ defaults "\x0A" on all systems.
Perl on Windows defaults to adding the :crlf PerlIO layer to handles. It causes CRLF to become LF on read, and the reverse on write. As such, when reading a Windows file on Windows, everything looks the same as it would on unix. If you read a line from a file containing "65 66 67 0D 0A", you'll get string "65 66 67 0A". chomp will happily remove the trailing line feed. When you'll have problems is when you read a Windows file on unix. The :crlf layer won't be present (by default), so the CR will appear in the read data along with the LF. chomp will happily remove (only) the trailing line feed, leaving the carriage return behind. Solution:
In reply to Re: chomp() function and windows text format
by ikegami
|
|