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

james28909:

What's the problem? It appears like you know what the task is, and the names of the primary functions you need (seek, read). Your pseudocode looks reasonable, so what's the problem?

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re: dynamic extractor based off static references in file (perl)

Replies are listed 'Best First'.
Re^2: dynamic extractor based off static references in file (perl)
by james289o9 (Acolyte) on Dec 06, 2013 at 07:49 UTC
    I have this code so far:
    open(my $infile, '<', "./file") or die "Cannot open file: $!"; binmode($infile); open(my $outfile, '>', "./reference1") or die "Cannot create file: $!" +; binmode($outfile); my $file = $infile; my $buffer = ''; sysseek $file, 0x15, 0; sysread $file, $buffer, 0x03; syswrite $outfile, $buffer; close $outfile; system ( 'pause' );
    I can get the first reference and I should be able to get the second reference without trouble. I am having problems figuring out how to put the $buffer into $reference.
    i tried this but it didnt work to well ofcourse:
    my $reference = $buffer; print $reference;
    it prints the data from $infile, but not in binary form. i guess my question really is, how can i put $buffer (binary data) into $location? any clarifications on what to do would be very much appreciated.

      it prints the data from $infile, but not in binary form

      Sure it does, you used binmode on both filehandles, you read the data, its binary form, there is no doubt; if you need a different format you'll need to do something about it

        Yes sir, and that happens to be where im stuck at. when i try to put the $buffer (location) into the variable $reference, it works. but when i try to use $location in sysseek i gives me the error:
        Argument "\0^D&" isn't numeric in sysseek