Reputation: 1980
I have a hash like :
$VAR1 = {
'x' => {
'Mathematics' => 82,
'Art' => 99,
'Literature' => 88
},
'y' => {
'Mathematics' => 97,
'Literature' => 67
}
.......
};
I need to get x, y
etc in an array(currently i don't know the values for x and y)
for eg
@arr = (x,y, z..);
Upvotes: 2
Views: 86
Reputation: 241858
Just use keys
. If the hash is in fact a hash reference, dereference it first:
my @keys1 = keys %hash;
my @keys2 = keys %$hash_ref;
Upvotes: 3