Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: How can I reference a hash value with an array
by jeffa (Bishop) on Feb 04, 2003 at 15:16 UTC | |
|
Re: How can I reference a hash value with an array
by dragonchild (Archbishop) on Feb 04, 2003 at 15:17 UTC | |
|
Re: How can I reference a hash value with an array
by broquaint (Abbot) on Feb 04, 2003 at 15:33 UTC | |
|
Re: How can I reference a hash value with an array
by Anonymous Monk on Feb 04, 2003 at 16:22 UTC | |
|
Re: How can I reference a hash value with an array
by hardburn (Abbot) on Feb 04, 2003 at 15:10 UTC |