$hash =
{
total_counts => tot_counts,
words => {
nw => 1,
}
};
@finalarray = get_array($hash);
print "@finalarray";
sub get_array {
my($hash) = @_;
my $array = [];
if(ref $hash eq 'HASH') {
foreach (keys %$hash) {
if(ref $hash->{$_} eq 'HASH') {
push @{$array} , $_;
push @{$array} , get_array($hash->{$_});
}
else {
push @{$array} , $_;
push @{$array} , $hash->{$_};
}
}
}
return @$array;
}
In reply to Re: importing all the values stored in an HoH into an array
by cankara
in thread importing all the values stored in an HoH into an array
by chinamox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |