develooper Front page | perl.perl5.porters | Postings from June 2004

[perl #30420] The PERL built-in read command reads more than one byte

Thread Previous | Thread Next
From:
Jon Christensen
Date:
June 23, 2004 02:21
Subject:
[perl #30420] The PERL built-in read command reads more than one byte
Message ID:
rt-3.0.9-30420-91213.16.5448052673957@perl.org
# New Ticket Created by  "Jon Christensen" 
# Please include the string:  [perl #30420]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=30420 >


HELP!!!

  I have been using perl for years now and have always been a
supporter.  However, a recent experience with PERL 5.8.0 on RedHat
LINUX 3.0AS has left me speachless.  The documentation (and I
have read a lot of it) for the read() command explicitly states
that read reads length bytes from a filehandle.  So to read one
byte you would:

read(FILEHANDLE,$buf,1)

  However, in some cases this will actually read multiple bytes.
This appears to somehow be related to handling of multi-byte 
characters.  The upshot is basically:

1) ls, stat, .... all report file as size 230 bytes.
2) read file 1 byte at a time incrementing a counter at each read.
3) file is read in 227 loops because there are three characters
that it believes are multibyte in the file and treats each as
a single byte.

How can PERL be this broken?

Jon Christensen


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About