develooper Front page | perl.perl5.porters | Postings from October 2013

[perl #120409] POSIX::read returns 0 but true at EOF

Thread Previous | Thread Next
From:
Bernhard Graf
Date:
October 29, 2013 13:51
Subject:
[perl #120409] POSIX::read returns 0 but true at EOF
Message ID:
rt-4.0.18-24528-1383052727-1128.120409-75-0@perl.org
# New Ticket Created by  Bernhard Graf 
# Please include the string:  [perl #120409]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=120409 >


The expected results in an endless loop:

perl -MPOSIX -wE 'my $buf = ""; my $f = POSIX::open("/etc/passwd"); my $r; do { $r = POSIX::read($f, $buf, 4096) } while $r;'

This works - and tells you why:

perl -MPOSIX -wE 'my $buf = ""; my $f = POSIX::open("/etc/passwd"); my $r; do { $r = POSIX::read($f, $buf, 4096) } until $r == 0; say $r;'

This is *not documented* and behaves differently from CORE::read().

-- 
Bernhard Graf


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