Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am writing a Perl script to convert a .elf file to .txt (Hexadecimal file) file but It is failing in a initial state?
Actual program going to convert a .elf to .txt file format with 80 character in a line something like this12345678 12345678 12345678 12345678 12345678 12345678 12345678 12345678
If the .txt would reach 1GB then stop the conversion and exit.
Can somebody help me? Am I using “pack” correctly?
#!/usr/bin/perl
use strict;
my @in;
my $out;
my $x;
my $y;
my $inputfile;
my $outputfile;
$inputfile = $ARGV[0];
$outputfile = $ARGV[1];
open(INPUT, "<$inputfile") || die "Error: unable to open $inputfile - $!\n";
@in = <INPUT>;
close(INPUT);
if (!@in) {
print("Error: no data in $inputfile\n");
exit(1);
}open(OUTPUT, ">$outputfile") || die "Error: unable to open $outputfile - $!\n";
for($x=0; $x<=$#in; $x = $x + 32) {
for ($y = 0; $y < 32; $y++ ) {
$out = pack("a4", $in[$y]);
#$out = unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
print OUTPUT $out;
}
print(OUTPUT "\n");}

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |