check this out, works great if yoru extracting files referenced by the header ;)
my $fileLocation = '';
my $fileSize = '';
my $fileName = '';
my $chunk = '';
#my $entry_Count = seek and read the count inside the file;
$entry_Count =~ s/(.)/sprintf("%02x",ord($1))/egs;
#print "There are $entry_Count entries in this file";
seek( $infile, 0x10, 0 ) || die "cannot seek file: $!";
for ( my $i = 1 ; $i <= $entry_Count ; $i++ ) {
read( $infile, $fileLocation, 0x08 );
read( $infile, $fileSize, 0x08 );
read( $infile, $fileName, 0x20 );
$fileLocation =~ s/(.)/sprintf("%02x",ord($1))/egs;
$fileSize =~ s/(.)/sprintf("%02x",ord($1))/egs;
$fileName =~ s/\0+$//;
print ("Found $fileName");
open( my $file, '>', "extracted/$fileName" ) || die "Cannot op
+en $fileName $!";
binmode($file);
seek( $infile, hex($fileLocation), 0 );
read( $infile, $chunk, hex($fileSize) );
syswrite( $file, $chunk );
#print ($file $chunk);
close($file);
}
print "Files/Data extracted";
the above will read a file in, and depending on an entry count (if one is defined in the file you are using) will extract the data that the header references. with the header being $entry_Count long ofcourse
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.