well see what the problem is, is that the search file only references which key you need, it doesnt contain the actual key. and the way the keyfile is formatted i have to search specifically for 3 matches then set pos as a variable with
$setPos = "@-" #
and then
seek $keysfile, $curPos, 0;
then skip 3 lines to the actual key and read 32 characters, then goto next line and read 64 characters, and store them into $erk, and $riv.
but i actually have got it working the way i want it, but have encountered a problem, which should be solvable easily enough...
the same keyset is used between different file revision, so say for instance if i need a version "16" key, it could actually be a version "12" key. so now i need to add abunch of if version statements like
if ($keyversion = "version=16"){ $keyversion = "version=12"; print $keyversion; #will print "version=12" and that lets me know it will search for +"version=12" and return the correct key/s } or if ($keyversion = "version=14"){ $keyversion = "version=12"; print $keyversion #should print "version=12"

was really hoping i could do this without a whole lot of if statements but im manually having to search this keyfile because the original tool to read this keysfile is in C and i do not understand it lol. but its working nicely, as long as all three regex matches work.

it searches the keys file for the expected values derived from the search file, and when it finds a match it skips three or four lines depending on the verison of the file, and then seeks to the actual key and reads 32 or 64 characters and stores them into $erk and $riv respectively.
i know this probably sounds crazy as all get out, but it works :devilface: and it returns the correct data everytime as long as there is an exact match, and thats where the predicament comes in, because the same key is used between different version of the file for some reason :l

also i am not very familiar with hashes. but there are different file types, different key versions, and file revisions of each file type.

In reply to Re^2: searching for multiple matches and then seek from last match by james28909
in thread searching for multiple matches and then seek from last match by james28909

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.