http://qs321.pair.com?node_id=891556


in reply to Re^11: Question about binary file I/O
in thread Question about binary file I/O

Gah, I've been playing with Python too much. You're right.

Replies are listed 'Best First'.
Re^13: Question about binary file I/O
by TheMartianGeek (Novice) on Mar 05, 2011 at 15:25 UTC
    So there is no single function that does that...well, that just sucks. I was hoping I could do it without needing seek(), but I guess if that's the only way, I don't have much of a choice. Isn't there a website somewhere where you can suggest features for the next version of Perl? That would be at least the second thing that I could think of.
      I was hoping I could do it without needing seek(),

      Why not just hide the seek inside a function of your own? Something like:

      sub printAt { my( $fh, $src, $nChars, $offset ) = @_; seek $fh, $offset, 0; return print $fh substr $src, 0, $nChars; } printAt( $fh, $s, 4, 1234 );

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Actually, that's a good idea. The problem with that, though, is that the print function completely erases the rest of the file. Now that I think about it, I don't know if I ever found a good way to overwrite characters in a file without erasing the rest of the file...