Leser: 17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/">
<title>DVB-Wiedergabeliste Satelit 1</title>
<trackList>
<track>
<title>tagesschau24</title>
<location>dvb-s://satno=1:frequency=10744000:voltage=18:srate=22000000</location>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>0</vlc:id>
<vlcoption>program=28721</vlcoption>
</extension>
</track>
</trackList>
</playlist>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use XML::Simple;
use strict;
use warnings;
my $filename = 'channels.xspf';
my $title = 'tagesschau24';
my $library = XMLin($filename,
ForceArray => [ 'track', 'location' ],
KeyAttr => { track => 'title' }
);
my $track = $library->{trackList}->{track}->{$title};
my @liste = (@{$track->{location}});
print "$liste[0]\n";
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
use XML::Simple;
use strict;
use warnings;
use Data::Dumper;
my $filename = 'channels.xspf';
my $title = 'tagesschau24';
my $library = XMLin($filename,
ForceArray => [ 'track', 'location', 'extension', 'vlcoption'],
KeyAttr => { track => 'title' }
);
my $track = $library->{trackList}->{track}->{$title};
my $track2 = $library->{trackList}->{track}->{$title}->{extension};
print Dumper $track;
print Dumper $track2;
my @liste = (@{$track->{location}});
print "$liste[0]\n";
my @liste2 = (@{$track2->{vlcoption}});
print "$liste2[0]\n";
print Dumper @liste2;
print "$liste2[0]\n";
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
C:\Users\benutzer\Desktop>test.pl
$VAR1 = {
'extension' => [
{
'vlcoption' => [
'program=28721'
],
'vlc:id' => '0',
'application' => 'http://www.videolan.org/vlc/playli
t/0'
}
],
'location' => [
'dvb-s://satno=1:frequency=10744000:voltage=18:srate=22
00000'
]
};
$VAR1 = [
{
'vlcoption' => [
'program=28721'
],
'vlc:id' => '0',
'application' => 'http://www.videolan.org/vlc/playlist/0'
}
];
dvb-s://satno=1:frequency=10744000:voltage=18:srate=22000000
Not a HASH reference at C:\Users\gutsch\Desktop\test.pl line 24.
my @liste2 = (@{$track2->{vlcoption}});
1 2 3
# gehe alle Einträge in @$track2 durch; sollte es eine (wahre) 'vlcoption' geben, # verwende sie; ansonsten mach nix my @liste2 = map { $_->{vlcoption} ? $_->{vlcoption} : () } @$track2;
1
2
3
C:\Users\benutzer\Desktop>test.pl
dvb-s://satno=1:frequency=10744000:voltage=18:srate=22000000
ARRAY(0x3242898)
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
use XML::Simple;
use strict;
use warnings;
use Data::Dumper;
my $filename = 'channels.xspf';
my $title = 'tagesschau24';
my $library = XMLin($filename,
ForceArray => [ 'track', 'location', 'extension', 'vlcoption'],
KeyAttr => { track => 'title' }
);
my $track = $library->{trackList}->{track}->{$title};
my $track2 = $library->{trackList}->{track}->{$title}->{extension};
#print Dumper $track;
#print Dumper $track2;
my @liste = (@{$track->{location}});
print "$liste[0]\n";
# gehe alle Einträge in @$track2 durch; sollte es eine (wahre) 'vlcoption' geben,
# verwende sie; ansonsten mach nix
my @liste2 = map { $_->{vlcoption} ? $_->{vlcoption} : () } @$track2;
print "Dumper Ausgabe\n";
print Dumper @liste2;
print "Inhalt von \@liste2\[0\]:\n";
print "$liste2[0]\n";
1 2 3 4
# gehe alle Einträge in @$track2 durch; sollte es eine (wahre) 'vlcoption' geben, # verwende sie; ansonsten mach nix; Da vlcoption eine Array-Referenz enthaelt, # dereferenzieren wir sie direkt via @{ $array_ref } my @liste2 = map { $_->{vlcoption} ? @{$_->{vlcoption}} : () } @$track2;