First of all what you are heading for looks like it is exactly what Dominus warned against here. (I suggest reading parts 2 and 3.)

Your actual question is answered by just using a hash:

$stuff{$1} = $2;

A deeper point though. If your code has (by your own admission) complex logic and complex conditions then there are good odds that if you step back and rethink it you can find ways to simplify. Try to do that.

Clean code isn't just aesthetic. Most of the money that will be spent on your code is spent in maintainance. Is the logic so messy that it would be hard for someone who did not know the code to figure it out and fix a bug or add a new feature? If so then how hard will it be for you in a month to fix bugs people find or deal with a changing spec?


In reply to Re (tilly) 1: Creating on-the-fly hashes? by tilly
in thread Creating on-the-fly hashes? by r.joseph

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.