In order to use the constant value of the hash I need to reference the keys of the hash by the array index.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 );
I.E. $type[0] = INTEGER => $hash{'$type[0]'}
I'm using this in conjunction with some Tk code I wrote
These 5 entry boxes get populated with the array @type# 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'); }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |