Leser: 15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$VAR1 = {
'xmlns' => 'http://www.ecb.int/vocabulary/2002-08-01/eurofxref',
'Cube' => {
'Cube' => [
{
'time' => '2010-10-13',
'Cube' => [
{
'rate' => '1.3958',
'currency' => 'USD'
},
{
'rate' => '114.23',
'currency' => 'JPY'
},
]
},
{
'time' => '2010-10-12',
'Cube' => [
{
'rate' => '1.3833',
'currency' => 'USD'
},
{
'rate' => '113.35',
'currency' => 'JPY'
},
]
},
]
},
'gesmes:Sender' => {
'gesmes:name' => 'European Central Bank'
},
'gesmes:subject' => 'Reference rates',
'xmlns:gesmes' => 'http://www.gesmes.org/xml/2002-08-01'
};
1 2 3 4 5 6 7 8 9 10 11 12
my $cube = $xml->{Cube}->{Cube}; # arrayref for my $item (@$cube) { my $time = $item->{time}; my $rate_curr = $item->{Cube}; # noch eine arrayref for my $item (@$rate_curr) { my $rate = $item->{rate}; my $curr = $item->{currency}; # mach was mit $time, $rate und $currency # schreib es in ein array, ... } }
1 2 3 4 5 6 7 8 9 10
my @kursdaten = map { my $time = $_->{'time'}; map { [ $time, $_->{'currency'}, $_->{'rate'}, ] } @{ $_->{'Cube'} } } @{ $data->{'Cube'}->{'Cube'} };