natxo has asked for the wisdom of the Perl Monks concerning the following question:
One of the examples I have assigns values to different HoH, and they have quite similar names: %hoh_groups_prod, %hoh_grous_test, %hoh_contacts_prod, %hoh_contacts_test. You get the idea. Theses HoH have data I want to access, I do not want to create them
So I thought: what if I create a hash, let's call it %choice, and create a table like:
If I create a subroutine, then i could callmy %choice = ( 'group_prod' => '$hoh_groups_prod', 'group_test' => '$hoh_groups_test', 'contacts_prod' => '$hoh_contacts_prod', 'contacts_test' => '$hoh_contacts_test', );
But what this does is obviously create a new variable $test and not access the values of $hoh_$object{'whatever'}my ( $object ) = @_; my $test = $choice{ $object };
Does it make sense?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash value $value
by choroba (Cardinal) on Feb 17, 2016 at 15:11 UTC | |
by natxo (Scribe) on Feb 17, 2016 at 15:21 UTC | |
|
Re: updated: hash value $value
by NetWallah (Canon) on Feb 17, 2016 at 17:13 UTC | |
by natxo (Scribe) on Feb 18, 2016 at 12:11 UTC | |
|
Re: hash value $value
by Anonymous Monk on Feb 17, 2016 at 15:08 UTC |