in reply to (tye)Re: Manipulating Binary files
in thread Manipulating Binary files

For a one-shot program, I'd be happy to use your code. However, if one is likely to use this repeatedly (which it doesn't sound like), then there is a potential bug. What happens if 0\x0D is the 4,096th character and 0x0A is the 4,097th? That would be annoying to track down (ain't boundaries a pain?).

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

  • Comment on (Ovid) Re: (tye)Re: Manipulating Binary files

Replies are listed 'Best First'.
(tye)Re2: Manipulating Binary files
by tye (Sage) on May 14, 2001 at 20:23 UTC

    Oops.

    { binmode(INPUT); binmode(OUTPUT); local $_= ""; while( read( INPUT, $_, 4096, length($_) ) ) { if( s/^.*?(\x0d\x0a)/$1/s ) { print OUTPUT $_; last; } substr( $_, 0, -1 )= ""; } print OUTPUT $_ while read INPUT, $_, 4096; }
    Thanks for catching that.

            - tye (but my friends call me "Tye")