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
Jon Christensen
June 23, 2004 02:21
[perl #30420] The PERL built-in read command reads more than one byte
Message ID:
# New Ticket Created by  "Jon Christensen" 
# Please include the string:  [perl #30420]
# in the subject line of all future correspondence about this issue. 
# <URL: >


  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:


  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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About