Have you got the second data file in the current directory?
I link perl6 to /usr/local/bin, change to the directory with the text
file (skaters.txt) and script (skatersv2.pl), and then run.
Richard
Will Coleda via RT wrote:
On Sat Jan 10 12:19:38 2009, richardh wrote:
Getting a wierd segmentation fault with the following program (also
attached).
I am using rakudo from parrot 35286
When I run the program below, it runs and I get almost the right
answer
(but uninitialised values and
incorrect output).
But when I comment out the 'say' line and uncomment the line below it,
I
get a segmentation fault.
#!/usr/local/bin/perl6
# Solution to Advanced Event 2, 2008 scripting games,
http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/aevent2.mspx
use v6;
my %players;
my $scores = open('./skaters.txt', :r) or die $!;
my $name;
my @list;
for =$scores {
($name,@list) = .split(/\,/);
@list .=sort;
%players{$name} = ([+] @list[2..6]) / 5;
};
my @ranking = %players.sort: { .value };
for <Gold Silver Bronze> -> $m {
given pop @ranking {
say "$m Medal: " ~ %players{$_} ~ ', ' ~ $_;
# say "$m Medal: $_";
};
};
I don't get a segfault; I'm getting:
Unable to open filehandle
current instr.: 'open' pc -7966446 ((unknown file):-1)
called from Sub 'open' pc 3939 (src/classes/List.pir:188)
called from Sub 'open' pc 18003 (src/builtins/io.pir:78)
called from Sub '_block14' pc 95 (EVAL_21:52)
called from Sub '!UNIT_START' pc 16736 (src/builtins/guts.pir:298)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 950
(src/PCT/HLLCompiler.pir:527)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1275
(src/PCT/HLLCompiler.pir:688)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1456
(src/PCT/HLLCompiler.pir:778)
called from Sub 'parrot;Perl6;Compiler;main' pc 20314 (perl6.pir:158)
this with parrot r35356.
Regards.