I
IJALAB
Hi All,
I have a file in the following format in txt file
ff68 adde ed5b 9ddc fe3d 7ad8 cf1c 2f39 c81c fbde be2a fcdf b9d9 e838 6a6c 0d4e 493e 9d2a 5f3c cc89 490c 29c9 efad 3d7e fc1b fb2b 3cae 7e0b 9c2f 3d6a 9df9 598e 5cfb daaa 2deb 79bd 1d99 8da8 98ab bfda b87d 194e ce2b a9db a899 cd6a 5af8 793c 5e1c af9e cf3c 9c9e c8bc fa9d ed9b 0bde aff8 7bcd 9fde 1abe 4b8b 5959 4839 2b9e 0d69 1b29 3d7d 0e9f ccba 2e8b f94a cbed fe3e 5dbe ad1a eda9 ce1d cf7a 3fca bc8e ff08 cbda 69bf cd1d
This is basically a jpeg file content and i need to make this file to .bin file so that i want to check if the jpeg is opening fine.
Can someone help on how this can be done. I am trying with the following code but since i have not used pack till now, i am not sure of my mistake. thanks for the help.
#!/usr/bin/perl
$buffer = "";
$infile = "Jpeg_hex.txt";
$outfile = "binary.bin";
open (INFILE, "<", $infile) or die "Not able to open the file. \n";
open (my $outfile, ">:raw", "binary.bin") or die "Not able to open the filefor writing. \n";
binmode (OUTFILE);
local $/ = \1;
while ( my $byte = <INFILE> ) {
print $outfile pack('s<', $byte) ;
}
close (INFILE) or die "Not able to close the file: $infile \n";
close ($outfile) or die "Not able to close the file: $outfile \n";
regards
bala
I have a file in the following format in txt file
ff68 adde ed5b 9ddc fe3d 7ad8 cf1c 2f39 c81c fbde be2a fcdf b9d9 e838 6a6c 0d4e 493e 9d2a 5f3c cc89 490c 29c9 efad 3d7e fc1b fb2b 3cae 7e0b 9c2f 3d6a 9df9 598e 5cfb daaa 2deb 79bd 1d99 8da8 98ab bfda b87d 194e ce2b a9db a899 cd6a 5af8 793c 5e1c af9e cf3c 9c9e c8bc fa9d ed9b 0bde aff8 7bcd 9fde 1abe 4b8b 5959 4839 2b9e 0d69 1b29 3d7d 0e9f ccba 2e8b f94a cbed fe3e 5dbe ad1a eda9 ce1d cf7a 3fca bc8e ff08 cbda 69bf cd1d
This is basically a jpeg file content and i need to make this file to .bin file so that i want to check if the jpeg is opening fine.
Can someone help on how this can be done. I am trying with the following code but since i have not used pack till now, i am not sure of my mistake. thanks for the help.
#!/usr/bin/perl
$buffer = "";
$infile = "Jpeg_hex.txt";
$outfile = "binary.bin";
open (INFILE, "<", $infile) or die "Not able to open the file. \n";
open (my $outfile, ">:raw", "binary.bin") or die "Not able to open the filefor writing. \n";
binmode (OUTFILE);
local $/ = \1;
while ( my $byte = <INFILE> ) {
print $outfile pack('s<', $byte) ;
}
close (INFILE) or die "Not able to close the file: $infile \n";
close ($outfile) or die "Not able to close the file: $outfile \n";
regards
bala