rsennat has asked for the wisdom of the Perl Monks concerning the following question:

hi all,

I am dynamically generating a hash like this,
push @{$hoh{$component}->{$cmd}->{$testcase} }, [$testsuite_type, $pla +tform_type, $view_type ];
Now i need a hash only
$hoh{$component}->{$cmd}->{$testcase}
and not the other info.
Basically I would like to convert the original hash to,
component=> cmd => testcase

thanks

Replies are listed 'Best First'.
Re: hash generation
by GrandFather (Saint) on Nov 15, 2005 at 20:52 UTC

    You have shown us a line of code with 7 unknown entities and expect us to read your mind sufficiently to tell you how you want to change the line to do something else? Try starting with the code here:

    use warnings; use strict; use Data::Dumper; my %hoh; push @{$hoh{'this'}->{'that'}->{'theOther'} }, ['eggs', 'bacon', 'chee +se']; print Dumper (\%hoh);

    which prints:

    $VAR1 = { 'this' => { 'that' => { 'theOther' => [ [ 'eggs', 'bacon', 'cheese' ] ] } } };

    and telling us what you would rather see printed.


    Perl is Huffman encoded by design.
Re: hash generation
by Fletch (Bishop) on Nov 15, 2005 at 20:34 UTC

    Erm, $hoh{$component}->{$cmd}->{$testcase} contains an arrayref which contains one or more arrayrefs which you've pushed into it. There's no other hashes in what you've shown. Perhaps you could clarify what hash it is you're interested in . . .