in reply to Re: Random read/write on a block device
in thread Random read/write on a block device

See, I missed sysseek() completely... very impressive.

About the docs you refer to, that's what I thought it meant but I was unsure since it overlaps with what substr() does, and passing unused data to syswrite() seems like an odd thing to do. Thanks for clearing it up :-)

-- Time flies when you don't know what you're doing
  • Comment on Re^2: Random read/write on a block device

Replies are listed 'Best First'.
Re^3: Random read/write on a block device
by ikegami (Patriarch) on Jun 25, 2009 at 16:15 UTC

    passing unused data to syswrite() seems like an odd thing to do.

    Since you can't control how many bytes actually get written, it makes it very easy to use syswrite:

    my $to_write = length($msg); while ($to_write) { my $written = syswrite($fh, $msg, $to_write, -$to_write) or die "syswrite: $!\n"; $to_write -= $written; }