[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] editing binary file with perl
- Subject: [ale] editing binary file with perl
- From: jb at sourceillustrated.com (John Wells)
- Date: Sat, 12 Apr 2003 22:22:17 -0400 (EDT)
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