in reply to Re: Binary conditionals
in thread Binary conditionals
#!/usr/bin/perl
open my $in, '<:raw', 'out.dat' or die $!;
open my $out, '>:raw', 'outfile.jpg' or die $!;
local $/ = \1024;
my $byte;
while (read($in, $byte, 1)) {
if($byte == x00){
$byte = chr(x17);}
elsif($byte == x17){
$byte = chr(x00);}
elsif($byte == x4E){
$byte = chr(x42);}
elsif($byte == x42){
$byte = chr(x4E);}
elsif($byte == x24){
$byte = chr(x90);}
elsif($byte == x90){
$byte = chr(x24);}
print $out $byte;
}
close $in or die $!;
close $out or die $!;
all it prints is many nulls and sporadic digits 1..9. I've even tried this with an if($byte eq chr(x00)) but it doesn't work eighther.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Binary conditionals
by moritz (Cardinal) on Sep 30, 2008 at 18:40 UTC | |
by bunnym4n (Novice) on Sep 30, 2008 at 18:53 UTC | |
|
Re^3: Binary conditionals
by jwkrahn (Abbot) on Sep 30, 2008 at 19:21 UTC |