[ale] editing binary file with perl

John Wells jb at sourceillustrated.com
Sat Apr 12 22:22:17 EDT 2003


I'm trying to emulate a file copy (don't ask) at a binary level with Perl.
 The intent is a poc...my next step is to first strip off a certain number
of bytes from the head of the file before printing the rest to another
file, but I wanted to get this working first for a sanity check.

Here's the code:

open(FP, "<input.bin");
open(OP, ">output.bin");

while ($c=getc(FP))
{
  printf OP "%c", $c;
}


However, this doesn't copy the file, as expected.  It does print some
chars to the file, but they're essentially garbage.

What am I missing here?

Thanks!

John



_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list