Question

I have this perl code and I'm not able to figure out one thing.

my %instr_enabled= ();

foreach my $instr (@{$attrib->get_A_instructions()})
{
    %instr_enabled = (
        $instr->{instr} => {
            enable     => $instr->{enable},
            group_name => $instr->{test_category},
        }
    );
    print Dumper(\%instr_enabled);
}
foreach my $instr (sort keys( %instr_enabled ))
{
    if($version eq "v8")
    {
        next unless ($instr =~ /$group_name_regex/);
        chomp($instr);
    }
    else
    {
        print("Entering V7 test name\n");
        my $test_name = $instr->group_name; 
    }
}

How do I access the groupname value which is hash of hashfor the last statement

Was it helpful?

Solution

$instr_enabled{$instr}{group_name};

This might not be the best reference but you can find more details here: http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top