Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^12: Question about binary file I/O

by tilly (Archbishop)
on Mar 05, 2011 at 10:45 UTC ( #891556=note: print w/replies, xml ) Need Help??

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...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891556]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2021-01-28 00:08 GMT
Find Nodes?
    Voting Booth?