Depending on platform, the \n sequence is converted by perl to:
Unix: octal \012 hex 0xA dec 10 LF may be \n
Dos: octal \015\012 hex 0xD0xA dec 13 10 CRLF may be \r\n
Max: octal \015 hex 0xD dec 13 CR may be \r
Although perl works for you trying to allow you to just use
\n as your newline delimiter and let it sort the platform
dependent details, many common *internet protocols* specify the
\015\012 sequence and unfortunately the values of Perl's \n and \r
are not reliable since they can and do vary across platforms.
I suspect that $textfield is named from its HTML source so you
will probably want to use a truly portable solution like this:
$textfield =~ s/\015\012|\015|\012//g;
If you prefer hex to octal :-)
$textfield =~ s/\xD\xA|\xD|\xA//g;
If you are confused by the \012 or \xA notation all this is
saying to perl is what I want you to match is the ASCII char
decimal 10 == octal 12 == hex A == binary 1010
In expanded commented /x form:
$textfield =~ s/ # substitute
\015\012 # a CRLF sequence (DOS, MIME...)
| # or
\015 # a lone LF (mac)
| # or
\012 # a lone LF (unix)
/ # with literal ''
/xg; # /x allow comments, /g do globally
tachyon |