But I am having trouble taking this hex representation and recreating the binary file with it. Here is the script I have currently that is not workingmy $buffer; open INFILE, "test.bin" or die "Can't open test.bin for reading: $!\n" +; open OUTFILE, ">test.bin" or die "Can't open test.bin for writing: $!\ +n"; select OUTFILE; binmode INFILE; while (read(INFILE, $buffer, 1) and printf("%X", ord($buffer))){}; print "\n";
This code just write a bunch of number to the binary file which is not what I want. Anyone have any ideas on what I am doing wrong?my $buffer; open INFILE, "test.text" or die "Can't open test.txt for reading: $!\n +"; open OUTFILE, ">test_updated.bin" or die "Can't open test_updated.bin +for writing: $!\n"; binmode OUTFILE; my $line = <INFILE>; chomp $line; my @list = split //, $line; my $hex_value; my $i =1; foreach my $character (@list) { if($i%2 == 0) { $hex_value .= $character; syswrite OUTFILE, hex($hex_value); } elsif($i%2 == 1) { $hex_value = "0x".$character; } $i++; }
In reply to Recreating a binary file from hex representation by choedebeck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |