On Wed, 27 Aug 2003 12:38:55 +0200, Peter J. Holzer wrote:

Hi Peter

> On 2003-08-27 12:06:19 +0200, Waldemar ?urowski wrote:
>
>> W li?cie z wto, 26-08-2003, godz. 18:33, Jeff Zucker pisze: chomp
>> $line; { local $/ = "\r"; chomp $line }
>>
>> Would help to remove both \015 and \012, or only \012, or only
>> \015 from the end of a line?
>>
>
> Yup. However, while your method may actually be faster (haven't
> benchmarked it), I find
>
> $line =~ s/\r?\n?$//s;
>
>
> somewhat more readable.

True, but it doesn't work, so readability has too high a priority:
-----><8-----
#!/usr/bin/perl

use strict;
use warnings;

# -----------

my($s) = "Data\n\r";

print "Length: ", length($s), ". \n";

$s =~ s/\r?\n?$//s;

print "Length: ", length($s), ". \n";
-----><8-----

Output:
-----><8-----
Length: 6.
Length: 5.
-----><8-----

Ideally, the final length would be 4, would it not?
--
Cheers
Ron Savage, [EMAIL PROTECTED] on 27/08/2003
http://savage.net.au/index.html

Reply via email to