I didn't get this working with the -pi switches, but looks to me like shmem has a solution. If all else fails, what needs to be done without the -pi complication is straightforward:
#!usr/bin/perl use strict; use warnings; open (IN, '<','src.bin') or die $!; binmode IN; open (OUT, '>','srcnew.bin') or die $!; binmode OUT; my $inbuf = do {local $/; <IN> }; $inbuf =~ s/w/v/; print OUT $inbuf; __END__ C:\PROJEC~1\testing>debug src.bin -d 62 69 6E 0A 00 65 6E 63-6F 64 65 64 00 66 69 6C bin..encoded.fil 65 00 72 3A 0D 00 6E 3A-0A 00 6E 72 3A 0A 0D 00 e.r:..n:..nr:... 72 6E 3A 0D 0A 00 77 69-74 68 00 45 4F 4C 2D 6C rn:...with.EOL-l 69 6B 65 00 73 65 71 75-65 6E 63 65 73 00 00 00 ike.sequences... 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ -q C:\PROJEC~1\testing>debug srcnew.bin -d 62 69 6E 0A 00 65 6E 63-6F 64 65 64 00 66 69 6C bin..encoded.fil 65 00 72 3A 0D 00 6E 3A-0A 00 6E 72 3A 0A 0D 00 e.r:..n:..nr:... 72 6E 3A 0D 0A 00 76 69-74 68 00 45 4F 4C 2D 6C rn:...vith.EOL-l 69 6B 65 00 73 65 71 75-65 6E 63 65 73 00 00 00 ike.sequences... 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ -q
Update: edited out beginning line info (byte offset, etc) from the debug output in the hopes that the lines will display better on Perl Monks. "debug" is a standard Windows command from the Command Line.

I will also add as a comment that although it is possible to preserve the line endings in a file, I almost always find that this is not desirable. You can wind up with mixed line endings that Perl can deal with, but other programs cannot. Perl will write a line ending appropriate for the platform being used for that "write". So: read the line, print the line is often the best way. That "normalizes" the line endings.


In reply to Re: binmode i/o for perl -pi in-place editing by Marshall
in thread binmode i/o for perl -pi in-place editing by pryrt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.