Let's say we have the following code:
[code=perl]
my $VAR1 = {
'target' => {
'oranges' => {
'size' => 'big'
},
'apples' => {
'size' => 'small'
}
}
}
print $VAR1;
[/code]
Now, to get the size of apples, we would use:
[code=perl]
print $VAR1->{'target'}->{'oranges'}->{'size'};
[/code]
But to do this, I have to know that there are oranges stored there, and that their size is defined.
How can I iterate all elements that are stored? I would like to display:
oranges, size: big
apples, colour: red
[code=perl]
my $VAR1 = {
'target' => {
'oranges' => {
'size' => 'big'
},
'apples' => {
'size' => 'small'
}
}
}
print $VAR1;
[/code]
Now, to get the size of apples, we would use:
[code=perl]
print $VAR1->{'target'}->{'oranges'}->{'size'};
[/code]
But to do this, I have to know that there are oranges stored there, and that their size is defined.
How can I iterate all elements that are stored? I would like to display:
oranges, size: big
apples, colour: red
Comment