http://www.perlmonks.org?node_id=859263

reedx032 has asked for the wisdom of the Perl Monks concerning the following question:

I downloaded the latest rakudo star and built it on Mac OS X 10.5 with gcc 4.01 supplied with xcode 3.1.4. The tests appear to pass. I then downloaded the using perl 6 book and tried the first example
use v6; my $file = open 'scores'; my @names = $file.get.split(' '); my %matches; my %sets; for $file.lines -> $line { my ($pairing, $result) = $line.split(' | '); my ($p1, $p2) = $pairing.split(' vs '); my ($r1, $r2) = $result.split(':'); %sets{$p1} += $r1; %sets{$p2} += $r2; if $r1 > $r2 { %matches{$p1}++; } else { %matches{$p2}++; } } my @sorted = @names.sort({ %sets{$_} }).sort({ %matches{$_} }).reverse +; for @sorted -> $n { say "$n has won %matches{$n} matches and %sets{$n} sets"; }
on the input
Beth Ana Charlie Dave Ana vs Dave | 3:0 Charlie vs Beth | 3:1 Ana vs Beth | 2:3 Dave vs Charlie | 3:0 Ana vs Charlie | 3:1 Beth vs Dave | 0:3
The following error is generated upon running the program:
Method 'split' not found for invocant of class '' in <anon> at line 12:type.p6 in main program body at line 1
I've tried both retyping the code and directly copy-pasting from the book and the same results are observed. Has anyone successfully run the code in the book. I'm not sure if this is an issue specific to my build, or if there is a mistake in the code in the book. Thanks, Dana