Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891556]
help
Chatterbox?
[LanX]: Oh, you spread measles in your saliva?
[LanX]: ... and why did you bite hos daughter?
[LanX]: *his
[holli]: And this guy was also Anti-Vaxx and I just snapped. I shoed him all over the yard
[james28909]: biting between the legs? now thats my kind of religion.
[holli]: and back into the building, saw him later peeking out of the window looking scared. It was hilarious.
[LanX]: Let's get physical...
[james28909]: wish i could stay and chat. i have an unsuspecting client to give an estimate to. muhhahaha

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2017-12-13 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?