Thread Frage zum ersten Beispiel aus dem Perl6-Buch (3 answers)
Opened by Kuerbis at 2012-12-04 12:07

Kuerbis
 2012-12-04 12:07
#163896 #163896
User since
2011-03-20
938 Artikel
BenutzerIn
[default_avatar]
Wenn ich dieses Skript ausführe (das erste Beispiel im perl6-book)
bekomme ich eine Menge solcher Fehlermeldungen:
Quote
use of uninitialized value of type Any in string context in block at ./perl6.pl:23
use of uninitialized value of type Any in string context in block at ./perl6.pl:24
use of uninitialized value of type Any in string context in block at ./perl6.pl:28

Woran könnte das liegen?
Code (perl): (dl )
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
#!/usr/bin/env perl6
use v6;

my $file = open 'scores';
my @names = $file.get.words;

my %matches;
my %sets;

for $file.lines -> $line {
    my ( $pairing, $result ) = $line.split( ' | ' );
   
    my ( $p1, $p2 ) = $pairing.words;
    my ( $r1, $r2 ) = $result.split( ':' );

    if $r1 > $r2 {
        %matches{$p1}++;
    }
    else {
        %matches{$p2}++;
    }
       
    my @sorted = @names.sort({ %sets{$_} });
    @sorted   = @sorted.sort({ %matches{$_} });
    @sorted   = @sorted.reverse;
    
    for @sorted -> $n {
        say "$n has won %matches{$n} matches and %sets{$n} sets";
    }
}

View full thread Frage zum ersten Beispiel aus dem Perl6-Buch