syswrite

syswriteFILEHANDLE,SCALAR,LENGTH,OFFSETsyswriteFILEHANDLE,SCALAR,LENGTHsyswriteFILEHANDLE,SCALAR
This function tries to write LENGTH
bytes of data from variable SCALAR to the
specified FILEHANDLE using the
write(2) syscall. The function returns the number
of bytes written, or undef on error.
The OFFSET, if specified, says from where in
the string to start writing. (You might do this if you were using the
string as a buffer, for instance, or if you needed to recover from a
partial write.) A negative OFFSET specifies
that writing should start that many bytes backward from the end of the
string. If SCALAR is empty, the only
OFFSET permitted is 0. An exception is raised
if LENGTH is negative or if
OFFSET points outside the string.
To copy data from filehandle FROM into filehandle TO, you can use something like:
use Errno qw/EINTR/; $blksize = (stat FROM)[11] || 16384; # preferred block size? while ($len = sysread FROM, $buf, $blksize) { if (!defined $len) { next if $! == EINTR; die "System read error: $!"; } $offset = 0; while ($len) { # Handle partial writes $written ...