Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #33963] read and readline opcodes don't mix

8 views
Skip to first unread message

Matt Diephouse

unread,
Jan 27, 2005, 7:10:19 PM1/27/05
to bugs-bi...@rt.perl.org
# New Ticket Created by Matt Diephouse
# Please include the string: [perl #33963]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=33963 >


harmony:~/Projects/parrot ezekiel$ cat test.pir
.sub main @MAIN
$P0 = open "test.pir", "<"
$S0 = readline $P0
print $S0
$S1 = read $P0, 3
print $S1
print "\n"
.end
harmony:~/Projects/parrot ezekiel$ parrot test.pir
.sub main @MAIN
readline: buffer too short
harmony:~/Projects/parrot ezekiel$

The docs say that read is a quick hack (see #33915), so I'm not sure
this is a surprise.

--
matt diephouse
http://matt.diephouse.com

Leopold Toetsch

unread,
Jan 28, 2005, 3:53:01 AM1/28/05
to perl6-i...@perl.org
Matt Diephouse <parrotbug...@parrotcode.org> wrote:
> $S0 = readline $P0
> print $S0
> $S1 = read $P0, 3

Mixing readline and read isn't really a good idea. Did you try to turn
on/off buffering before changing read modes? See PIO.setbuf().

leo

Matt Diephouse

unread,
Jan 28, 2005, 10:15:50 AM1/28/05
to l...@toetsch.at, perl6-i...@perl.org

Regardless of whether or not it's a good idea, the documentation for
read says it should work:

"Read up to N bytes from standard input stream If stream is
linebuffered, will return at EOL, for files it will read
MIN(MAX(avail, N), 65535) bytes. Warning: This is a quick hack."

Unless I'm reading that incorrectly?

Leopold Toetsch

unread,
Jan 29, 2005, 9:13:37 AM1/29/05
to perl6-i...@perl.org
Matt Diephouse <parrotbug...@parrotcode.org> wrote:

> harmony:~/Projects/parrot ezekiel$ cat test.pir
> .sub main @MAIN
> $P0 = open "test.pir", "<"
> $S0 = readline $P0
> print $S0
> $S1 = read $P0, 3
> print $S1
> print "\n"
> .end
> harmony:~/Projects/parrot ezekiel$ parrot test.pir
> .sub main @MAIN
> readline: buffer too short

Should be fixed now. Tests are welcome.

leo

0 new messages