0

I have the following object

$VAR1 = [
          {
            'value' => {
                         'a' => 'd',
                         'b' => 'e',
                         'c' => 'f'
                       }
          },
          {
            'value' => {
                         'a' => 'g',
                         'b' => 'h',
                         'c' => 'x'
                       }
          }
        ];

I have to traverse this object to get values for a,b,c. Please can someone help ?

1 Answers1

0

Try this:

foreach my $arr (@$VAR1) {
    print $arr->{value}->@{ ('a'..'c') };
}

Or even shorter :

print map{ $_->{value}->@{ ('a'..'c') } } @{ $VAR1 }[0..$#$VAR1];

OUTPUT

defghx
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223