Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

is 0 bytes read EOF ?

by abachus (Monk)
on Sep 11, 2006 at 21:19 UTC ( #572403=perlquestion: print w/replies, xml ) Need Help??

abachus has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a quick question :
When reading from a handle, with say sysread(), if the call returns 0 bytes read, is this a reliable indication that the handle pointer (for want of better terminology) is at EOF ?

many thanks,

Isaac.

Replies are listed 'Best First'.
Re: is 0 bytes read EOF ?
by blue_cowdawg (Monsignor) on Sep 11, 2006 at 21:26 UTC
        When reading from a handle, with say sysread(), if the call returns 0 bytes read, is this a reliable indication that the handle pointer (for want of better terminology) is at EOF ?

    This from perldoc -f sysread "There is no syseof() function, which is ok, since eof() doesn’t work very well on device files (like ttys) anyway. Use sys- read() and check for a return value for 0 to decide whether you’re done. "

    Does this answer the question?

    This by the way must be my "evil" post because it is the 666th post! BWAHAHAHAHAAHAHAHA!!!


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: is 0 bytes read EOF ?
by friedo (Prior) on Sep 11, 2006 at 21:28 UTC
    As the docs indicate, a return of zero means EOF, and a return of undef means error.
Re: is 0 bytes read EOF ?
by GrandFather (Saint) on Sep 11, 2006 at 21:30 UTC

    The documentation for sysread says that it returns 0 on EOF.


    DWIM is Perl's answer to Gödel
      Thanks monks, I just wanted to be sure, i'm putting together a bit of code with select(), i will post here when help is needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://572403]
Approved by blue_cowdawg
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2022-08-15 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?