| Input and output functionsFixed-length unbuffered input from a filehandleDaftar Isi - sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
- sysread FILEHANDLE,SCALAR,LENGTH
Attempts to read LENGTH bytes of data into variable SCALAR from thespecified FILEHANDLE, using the read(2). It bypassesbuffered IO, so mixing this with other kinds of reads, print ,write , seek , tell , or eof can cause confusion because theperlio or stdio layers usually buffers data. Returns the number ofbytes actually read, 0 at end of file, or undef if there was anerror (in the latter case $! is also set). SCALAR will be grown orshrunk so that the last byte actually read is the last byte of thescalar after the read. An OFFSET may be specified to place the read data at some place in thestring other than the beginning. A negative OFFSET specifiesplacement at that many characters counting backwards from the end ofthe string. A positive OFFSET greater than the length of SCALARresults in the string being padded to the required size with "\0" bytes before the result of the read is appended. There is no syseof() function, which is ok, since eof() doesn't workwell on device files (like ttys) anyway. Use sysread() and checkfor a return value for 0 to decide whether you're done. Note that if the filehandle has been marked as :utf8 Unicodecharacters are read instead of bytes (the LENGTH, OFFSET, and thereturn value of sysread() are in Unicode characters).The :encoding(...) layer implicitly introduces the :utf8 layer.See binmode, open, and the open pragma, open. |
| |
|