Computing.Net > Forums > Programming > Perl : converting .elf (binary) to .txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Perl : converting .elf (binary) to .txt file

Reply to Message Icon

Name: Suba
Date: September 29, 2009 at 12:47:06 Pacific
OS: Windows XP
Subcategory: General
Comment:

I am writing a Perl script to convert a .elf file to .txt 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. 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 $inputfile;
my $outputfile;

sub totext() {
my @in;
my $out;
my $x;

@in = @_;
open(OUTPUT, ">$outputfile") || die "Error: unable to open $outputfile - $!\n";
for($x=0; $x<=$#in; $x++) {
$out = pack("B*", $in[$x]);
print OUTPUT $out;
} print("\n");
}


$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);
}
&totext(@in);



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Using Javascript under WS... Batch copy files on txt f...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Perl : converting .elf (binary) to .txt file

Perl : converting .elf (binary) to .txt file www.computing.net/answers/programming/perl-converting-elf-binary-to-txt-file/20055.html

Webpage content to TXT file www.computing.net/answers/programming/webpage-content-to-txt-file/14510.html

Convert .dll to .lib file www.computing.net/answers/programming/convert-dll-to-lib-file/9755.html