hi all-
one of my scripts parses a very complex log produced by a piece of lab equipment. the most reliable format that i've been able to put together for the parsing operation involves stepping through the log until a line is reached that signals the beginning of a set of results, which triggers the extraction operation, parses the values, checks to see if they've been stored before, and inserts them into a postgresql database. i only extract one record on each pass through the file, which may seem inefficient but is exhaustive and helps to assure that i don't miss a record ... this output file has all sorts of stuff in it.

i'm getting long winded - here's the rub. the key that identifies a unique run is the concantenation of three values, id, date, and time (date and time are both ascii representations extracted from the file). as a result, the constructed key can look like "12502-23-0110:13:53". in previous incarnations of the script i had simply issued a select againt the parent table to determine whether the value had previously been stored, but after updating my system to 5.6.1 and the latest Pg driver on cpan i found that a memory leak had been engendered by this scenario. rather than messing around with earlier versions to see if i could fix that, i decided to write a smarter lookup, dumping the keys into a hash and checking for the existence of the key there.

so i did (grin), extracting the keys with

my @keys=$count_stmnt->fetchall_arrayref(); $vals=@keys[0];
and then checking for the existence of the key with (exists $vals{$key}). the appropriate values are getting in the $vals hash ... i use ptkdb so i can evaluate that and see the values there, as is the $key value. except the exists function always returns "". from what i've read i'm pretty much going by the book implementing the exists function, and $key as a key works perfectly fine for database access ... i've set up a little web page as a query tool and issue queries against a joined view defined in postgresql using the same key field to associate the tables, and that works w/o any glitches.

i've given some thought that the problem may be associated with the "-"'s and ":"'s in the hash keys, wondering whether they create problems with the way the exists function looks through the hash, although it's clearly possible that i've missed something in how i'm implementing it.

any input would be appreciated.


In reply to hash key lookups failing by ralphie

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.