Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to inset "+" symbol in binary files ?

by Abigail-II (Bishop)
on Mar 24, 2004 at 14:48 UTC ( #339417=note: print w/replies, xml ) Need Help??


in reply to How to inset "+" symbol in binary files ?

Uhm, the same way as you do in non-binary files? If the file is small: open the file read/write, read in the file (in a scalar), insert "+" wherever you want it, seek back to the beginning of the file, write the scalar, close the file. If the file is large, open a temporary file for writing, open the original file for reading, read from the file up to the point where you want to insert the "+" while writing what you've read (in chunks) to the temporary file, write "+" to temporary file, read rest of file while writing it to the temporary file, close both files, move temporary file to original file.

Abigail

  • Comment on Re: How to inset "+" symbol in binary files ?

Replies are listed 'Best First'.
Re: Re: How to inset "+" symbol in binary files ?
by tcf22 (Priest) on Mar 24, 2004 at 15:07 UTC
    If you do it on Windows, you have to use binmode on the file handle.

    - Tom

      Not using windows for anything but games/shell windows to other systems and Office apps I've always been curious as to why this is the case. It seems odd to me that an OS would care what kind of file you are opening.
        Checkout the doc page for binmode. It has to do with conversion of newline characters.

        - Tom

      Always use binmode and you'll never get bit by this on any of the platforms it matters (windows is just one).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-01-17 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (52 votes). Check out past polls.

    Notices?