Quoteuse 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
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"; } }
1
2
3
4
5
6
7
Beth Ana Charlie Dave
2 Ana Dave | 3:0
3 Charlie Beth | 3:1
4 Ana Beth | 2:3
5 Dave Charlie | 3:0
6 Ana Charlie | 3:1
7 Beth Dave | 0:3