First off, you guys are awesome here, I have always got help with what i was trying to accomplish. I just hope that one day I can be as good as a programmer as alot of yall :) Ok to the point. I am using perl (active state perl latest build 64 bit). I have tried over and over to accomplish this. I have a file. I open the file and then binmode it. In the beginning of this file there are static references to the actual data. The references are as follows: file location, and file size. I need to setup a script that will find the file location and the filesize, then seek to that spot in the file and extract it. I can setup almost everything myself, but I just cannot get my head around how to accomplish this. here is a sort of flow chart if you will:
open file binmode file seek to static reference offset (file location) in file read a predefined byte length seek to static reference offset (file size) in file read a predefined byte length use that info (file location) to goto to the actual data. then extract (file size)
Hopefully you understand what i am trying to accomplish. Its sort of like a dynamic extractor. It extract data based of the information it finds in the static references.

EDIT:
Thank you all for helping. i finally got it to work like this:
open(my $infile, "<", "./file") or die "Cannot open file: $!"; # GET FILESIZE AND LOCATION $buffer1 = ''; $buffer2 = ''; seek $infile, 0x15, 0; read $infile, $location, 0x03; seek ($infile, 0x1D, 0); read ($infile, $filesize, 0x03); $location =~ s/(.)/sprintf("%02x",ord($1))/eg; $filesize =~ s/(.)/sprintf("%02x",ord($1))/eg; # GET FILENAME seek $infile, 0x20, 0; read $infile, $filename, 0x25; $filename =~ s/\0*$//g; print $filename, "\n"; my $directory = "extracted\\"; system "mkdir $directory"; # EXTRACT FILE open($newfile, '>', "extracted//$filename"); sysseek $infile, hex($location), 0; sysread $infile, $new, hex($filesize); syswrite $newfile, $new;

Thanks to everyone who took their time to help me :)

In reply to dynamic extractor based off static references in file (perl) by james289o9

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.