Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# syswrite

Perl 5 version 10.1 documentation
Go to top

# syswrite

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET

- syswrite FILEHANDLE,SCALAR,LENGTH
- syswrite FILEHANDLE,SCALAR

  Attempts to write LENGTH bytes of data from variable SCALAR to the specified FILEHANDLE, using the system call write(2). If LENGTH is not specified, writes whole SCALAR. It bypasses buffered IO, so mixing this with reads (other than `sysread())`, `print`, `write`, `seek`, `tell`, or `eof` may cause confusion because the perlio and stdio layers usually buffers data. Returns the number of bytes actually written, or `undef` if there was an error (in this case the errno variable `$!` is also set). If the LENGTH is greater than the available data in the SCALAR after the OFFSET, only as much data as is available will be written.

  An OFFSET may be specified to write the data from some part of the string other than the beginning. A negative OFFSET specifies writing that many characters counting backwards from the end of the string. In the case the SCALAR is empty you can use OFFSET but only zero offset.

  Note that if the filehandle has been marked as `:utf8` , Unicode characters are written instead of bytes (the LENGTH, OFFSET, and the return value of syswrite() are in UTF-8 encoded Unicode characters). The `:encoding(...)` layer implicitly introduces the `:utf8` layer. See "binmode", "open", and the `open` pragma, open.

Recently read

Tools

- Preferences