On Tue, 21 Jul 2015 13:35:37 -0700 Jim Gibson <j...@gibson.org> wrote:
> The data structure you have shown is not very efficient in tems of > data storage. Is this the actual data structure, or is it part of > something more complicated. For exampe, a more efficient use of space > would be this, which uses nested arrays instead of hashes: > > [ > [0, “string1"], > [1, “string2"], > [2, “string3"], > [2, “string4"] > ] my @data = ( [ "string1" ], [ "string2" ], [ "string3", "string4" ], ); Each string is pushed onto the anonymous array at its level. my @data = (); for my $pair ( @$original ){ push @{ $data[ $pair->{level} ]}, $pair->{value}; } -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/