< Perl Programming < Keywords

The syswrite keyword

The syswrite function tries to write LENGTH number of bytes from the SCALAR to the FILEHANDLE by using write(2) of UNIX. If LENGTH is not specified, the whole string is written.

Without an OFFSET, it writes the whole content of the SCALAR. If OFFSET is positive, OFFSET number of characters are skipped. If it is less than zero, it places the data this number of bytes before the end of the string. If OFFSET is greater than the string length, only the number of characters that exists are written.

syswrite returns the number of bytes actually written on success, or undef otherwise. For performance reasons, even if the FILEHANDLE has been set to operate on characters, the function tell() will return the byte offsets.

Do not use syswrite with reads or with eof, print, seek, tell, or write, as it bypasses normal buffered I/O.

If the FILEHANDLE has been marked as :utf8 Unicode, characters are written instead of bytes, and the return value of syswrite() is in Unicode characters.

Syntax

  syswrite FILEHANDLE, SCALAR, LENGTH, OFFSET
  syswrite FILEHANDLE, SCALAR, LENGTH
  syswrite FILEHANDLE, SCALAR

See also

syscallsysopensysreadsysseeksystemsyswrite
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.