"Xavier Noria" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Jun 6, 2006, at 14:16, John W. Krahn wrote:
>
>> Mr. Shawn H. Corey wrote:
>>>
>>> $output_file =~ s/\r//g;
>>> # chomp only removes linefeed characters \n
>>>
>>> # BTW, there is no such thing as a newline;
>>> # it is either a linefeed: \n ASCII LF 0x0A
>>> # or a carriage return: \r ASCII CR 0x0D
>>
>> "\n" is inherited from the C programming language and is the  newline 
>> escape
>> sequence.  On Unix and Unix-like systems the newline is equivalent  to 
>> the
>> ASCII line feed character but on other systems it could be one or more
>> different characters.
>
> To be more precise, "\n" in Perl is eq "\012" everywhere except in  Mac OS 
> pre-X, where it is eq "\015". In CRLF platforms like Win32  "\n" is 
> transparently converted to CRLF on writing and back on  reading by PerlIO 
> in text mode. Thus, in a regular line-oriented  script like
>
>   while (my $line = <FH>) {
>       # work with $line
>   }
>
> $line ends with "\n" but does not contain a pair CRLF (assuming  native 
> conventions in the input). On the other direction, the string  "foo\n" has 
> length 4 in all systems. When you print that string into  a file in text 
> mode on Windows the bytes on disk have an extra  "\015", but that's 
> transparent to the programmer. That's the point of  using "\n" as 
> logical/portable newline in Perl.
>
> I have written an article about newlines in Perl not yet published.  All 
> those fine details are explained there.
>
> -- fxn
>
--expect me to read it..do give me a link once done, thanks. 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to