On Dec 7, 2003, at 7:02 PM, Paul Johnson wrote:
On Sun, Dec 07, 2003 at 06:39:50PM -0800, drieux wrote:On Dec 7, 2003, at 5:40 PM, Bryan Harris wrote: [..]I have tried to strip the carriage return of the last field
$field[8] =~ s/\015//g;
Uh, isn't the carriage return code 13?
our $CRLF = "\015\012"; # "\r\n" is not portable
[jeeves: 42:] perl -e 'print ord("\n")' 10[jeeves: 43:] perl -e 'print ord("\r")' 13[jeeves: 44:]
I think we may have found the OOOPSIE...
I'm not absolutely sure what you are getting at.
$ perl -le 'print 015' 13
as others have noted, the old phrase was
<CR><LF>
carriage return, line feed, from the hey days of Real Teletypes. And yes, you did get to watch the carriage return, and THEN a LINE FEED.
<CR> :: 015 :: 13 :: "\r" <LF> :: 012 :: 10 :: "\n"
unix freaks forget that "\n" is used and interpretted by the stty to denote BOTH. DOS based systems will acutally put TWO characters, where as Mac boxes of the old school use the "\r".
So while I generally support the notion of chomp() at it will hunt for the 'last' "<CR><LF>" but may not pick of any of them on the inside of the string.
let us assume a data string of the form
foo<CR><LF>bar<CR><LF>
your regex would remove the <CR> and leave us with
foo<LF>bar<LF>
which SHOULD print out like
foo bar
since there was NO <CR> to return 'the print head' back to the zero-th position. The alternative is that it will confuse some systems and print out like
foo[]bar[]
So as a general rule of thumb, one can opt for the risky strategy of
s/\n|\r//g
or get 'literal' with say
s/\015|\012//g
and rip them out in octal.
ciao drieux
---
"I see bit streams...." - frightened proto-coder unaware of their powers
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>