6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
open(LIEDER,'lieder.txt');
%liste;
foreach (<LIEDER>) {
chomp $_;
($künstler, $titel) = split /\: /,$_;
$liste{$künstler} = $titel;
}
$nr = 0;
foreach (keys %liste) {
$nr = $nr + 1;
print "$nr) $_\n\t\ $liste{$_}\n";
}
close (LIEDER);
QuoteMadonna: Like a Prayer
Madonna: American Pie
Madonna: Frozen
Michael Jackson: Thriller
Michael Jackson: Bad
Michael Jackson: Billie Jean
[...]
Quote1) Madonna
Like a Prayer
American Pie
Frozen
2) Michael Jackson
Thriller
Bad
Billie Jean
3) [...]
Quote1) Madonna
Frozen
2) Michael Jackson
Billie Jean
3) [...]
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
#!/usr/bin/perl
use strict;
use warnings;
my $liste;
while (<DATA>) {
chomp $_;
my ($kuenstler, $titel) = split /\: /, $_;
push @{$liste->{$kuenstler}}, $titel;
}
my $nr = 0;
foreach (keys %$liste) {
print ++$nr, ') ', $_, "\n\t", join("\n\t", @{$liste->{$_}}), "\n";
}
_ _DATA_ _
Madonna: Like a Prayer
Madonna: American Pie
Madonna: Frozen
Michael Jackson: Thriller
Michael Jackson: Bad
Michael Jackson: Billie Jean
my ($kuenstler, $titel) = split(/\s*:\s*/, $_, 2);
1
2
3
4
5
6
7
8
9
10
my %artists = (
'Judas Priest' => ['Breaking the Law', 'Painkiller', 'Ram it Down'],
'Iron Maiden' => ['Number of the Beast', 'Brave New World'],
'Metallica' => ['Master of Puppets', 'One', 'Creeping Death']
);
for my $artist ( keys %artists ) {
for my $song ( @{ $artists{$artist} } ) {
print "$artist: $song\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
#!/usr/bin/perl
use strict;
use warnings;
my $liste;
my $nr;
for (<DATA>) {/^(.*): (.*)$/; push @{$liste->{$1}}, $2;}
foreach my $kuenstler (keys %$liste) {
print ++$nr,
') ',
$kuenstler,
"\n\t",
join("\n\t", @{$liste->{$kuenstler}}),
"\n";
}
_ _DATA_ _
Madonna: Like a Prayer
Madonna: American Pie
Madonna: Frozen
Michael Jackson: Thriller
Michael Jackson: Bad
Michael Jackson: Billie Jean
6 Einträge, 1 Seite |