in reply to Binary conditionals
open my $in, '<:raw', 'infile.dat' or die $!; open my $out, '>:raw', 'outfile.dat' or die $!; # reading with a bigger block size is much more efficient # than byte by byte reading local $/ = \1024; while (<$in>) { my $copy = $in; $copy =~ s/\x00/\x17/g; print $out $copy; } close $in or die $!; close $out or die $!;
Your code fails because it writes the number 23 (0x17), not the character 23. You can fix that with the chr function.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Binary conditionals
by Fletch (Bishop) on Sep 30, 2008 at 14:30 UTC | |
|
Re^2: Binary conditionals
by Illuminatus (Curate) on Sep 30, 2008 at 15:21 UTC | |
by moritz (Cardinal) on Sep 30, 2008 at 15:26 UTC | |
by bart (Canon) on Oct 01, 2008 at 12:55 UTC | |
|
Re^2: Binary conditionals
by bunnym4n (Novice) on Sep 30, 2008 at 18:22 UTC | |
by moritz (Cardinal) on Sep 30, 2008 at 18:40 UTC | |
by bunnym4n (Novice) on Sep 30, 2008 at 18:53 UTC | |
by jwkrahn (Abbot) on Sep 30, 2008 at 19:21 UTC |