Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

can some elaborate the difference between sysread/read sysseek/seek

by lightoverhead (Monk)
on Sep 26, 2013 at 19:12 UTC ( #1055883=perlquestion: print w/ replies, xml ) Need Help??
lightoverhead has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I am sort of confused about sysread/read, sysseek/seek.

It seems there is no practical difference between these functions.

Could someone enlighten me a bit? Thanks

Comment on can some elaborate the difference between sysread/read sysseek/seek
Re: can some elaborate the difference between sysread/read sysseek/seek
by wjw (Deacon) on Sep 26, 2013 at 19:40 UTC
    Have never used either, but the way I read the docs

    sysseek

    and

    sysread

    implies that one
    (seek) gets you to a place in the file measured in position units(unicode or bytes) and returns success or not,
    and the other (read)
    reads from that place for some length in position units(unicode or bytes).

    So one gets you to where you want to start, and the other returns scalar data from the start position up to the length you ask for... Hope that is helpful...

    • ...the majority is always wrong, and always the last to know about it...
    • ..by my will, and by will alone.. I set my mind in motion
      sysread() is normally used for very low level I/O.
      Normally in Perl, you shouldn't be doing that.
      This is possible, but there are buffering complications.

      read() and seek() are much more normal.
      Do not mix read, seek or sysread and sysseek together.

Re: can some elaborate the difference between sysread/read sysseek/seek
by davido (Archbishop) on Sep 26, 2013 at 20:21 UTC
Re: can some elaborate the difference between sysread/read sysseek/seek
by ikegami (Pope) on Sep 27, 2013 at 13:11 UTC

    sysread doesn't buffer. read buffers. On the rare occasions you need unbuffered IO (e.g. you want to use select), you need to use sysread and sysseek. (As such, sysread will always return as soon as data is available, if is there is data available than requested.) The rest of the time, you want to use read and seek.

Re: can some elaborate the difference between sysread/read sysseek/seek
by vsespb (Hermit) on Sep 27, 2013 at 13:19 UTC
    sysread could also returns errors like EINTR.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-11-01 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (227 votes), past polls