I've got a program where I have something like this:
$hashref = { key => ['value1', 'value2'], key2 => ['value3', 'value4'] + };

This is a nice little conversion trick where the keys are known CGI parameters, the first value in the array refers to a specific database column, and the second is for spitting out something nice if there's an error. This allows me to use one piece of code to do similar tasks in multiple tables in the database.

Now, I'm running into a new problem. I now have some CGI parameters that will not be known until runtime. I want the frontend script to admit these new parameters into the above reference based on what I do know about the parameters before runtime. I think this should work, but my eyes are playing tricks on me and making my brain stare in disbelief. Here's the admittance code:

foreach $param ($cgi->param) { if ($param =~ /^abc_/) { $hashref->{$param} = ['column', 'text']; } }

Why do I have the feeling of disbelief? Am I just crazy? Thanks for anyone who can see whether I've correctly addressed all the levels of anonymity here.

PsychoSpunk

P.S. I would just run this but I'm in the middle of a very big script that this is located in, and if it broke later, I would just post this message but with the statement that goes, "I can't make this work." This message is simply proactive debugging. :) ALL HAIL BRAK!!!


In reply to Referents Anonymous. by PsychoSpunk

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.