SPUG: lenght of string
Ken Clarke
kenslinux at shaw.ca
Tue Oct 5 16:31:01 CDT 2004
While we're on the subject of the length function...
I've noticed that ActiveState Perl v 5.8.3 seems to ignore the use bytes
pragma mentioned in the docs.
This snippet reports the length as 3 bytes when in fact it's 4:
"\x31\x0D\x0A\x33"
my $string = "1\n2";
do {
use bytes;
print length($string);
};
I had to add the following work around when setting the Content-Length HTTP
header for file downloading:
$size = length($download_file);
if ($^O =~ /win/i) {
my $cr_count = $$download_file =~ tr/\n//;
$cr_count ||= 0;
$size += $cr_count;
}
Comments?
>> Ken Clarke
>> Contract Web Programmer / E-commerce Technologist
----- Original Message -----
From: "O'neil, Jerome" <joneil at cobaltgroup.com>
To: <spug-list at mail.pm.org>
Sent: Tuesday, October 05, 2004 1:43 PM
Subject: RE: SPUG: lenght of string
> %length EXPR has always worked for me.
>
> perldoc -f length for wisdom.
>
> -J
More information about the spug-list
mailing list