Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Take variable name as hash name in multidimensional hash 1

Status
Not open for further replies.

nawlej

Programmer
Mar 26, 2004
380
0
0
US
Im trying to push an array onto a hash of a hash of a hash
it shoudl take this format:
Code:
%stripped{
          B{
            %"servicegroupname"{$node,$state)
           }
          }

I need to take the name that the variable $servicegroup holds, instead of it being %servicegroup. Would the correct syntax be (for the array as well):
Code:
push ($stripped{'B'{${$servicegroup}}}},@{$clustnode,$sysstate};
 
What is your goal ?
Is 3 dimensions really needed ?




[ponder]KrK
 
Yup, three dimensions. They are getting pulled out later for output.....

the 'B' in:

push ($stripped{'B'{${$servicegroup}}}},@{$clustnode,$sysstate};

will also vary from letters A-G, each letter has different meaning to the script, and therefore needs to be different. I just need to know how to make $servicegroup name the actual name of the hash, instead of %servicegroup name. Thanx.
 
I meant to post this for you yesterday.
Code:
my $stripped = {};
my @push_array = qw/here are some values/;
my $servicegroup = 'test';

push @{$stripped->{B}->{$servicegroup}}, @push_array;
print "@{$stripped->{B}->{$servicegroup}}";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top