I have the following two data structures:
my @type = qw(INTEGER INTEGER32 OCTET_STRING OBJECT_IDENTIFIER IPADDRE +SS COUNTER COUNTER32 GAUGE GAUGE32 UNSIGNED32 TIMETICKS OPAQUE COUNTE +R64); my %hash=( 'INTEGER' => INTEGER, 'INTEGER32' => INTEGER32, 'OCTET_STRING' => OCTET_STRING, 'OBJECT_IDENTIFIER' => OBJECT_IDENTIFIER, 'IPADDRESS' => IPADDRESS, 'COUNTER' => COUNTER, 'COUNTER32' => COUNTER32, 'GAUGE' => GAUGE, 'GAUGE32' => GAUGE32, 'UNSIGNED32' => UNSIGNED32, 'TIMETICKS' => TIMETICKS, 'OPAQUE' => OPAQUE, 'COUNTER64' => COUNTER64 );
In order to use the constant value of the hash I need to reference the keys of the hash by the array index.

I.E. $type[0] = INTEGER => $hash{'$type[0]'}

I'm using this in conjunction with some Tk code I wrote

# Create the list of BrowseEntry boxes for the right frame for (1..5) { $type_e[$_] = $right_frame_bottom->BrowseEntry( -variable => \$type[$_], -listwidth => '45', -width => 20, -choices => [@type], )->pack(-side => 'top', -pady => '3'); }
These 5 entry boxes get populated with the array @type

Any ideas, or am I making this to complicated?

update (broquaint): escaped bare square brackets


In reply to How can I reference a hash value with an array by Anonymous Monk

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.