fork download
  1. #!/usr/bin/env perl6
  2.  
  3. my %grade = "grades.txt".IO.lines.map: {
  4. m:s/^ (\w+) (<[A..F]><[+-]>?) $/ or die "Can't parse line '$_'";
  5. ~$0 => ~$1
  6. };
  7.  
  8. say "Zsófia's grade: %grade<Zsófia>";
  9.  
  10. say "List of students with a failing grade:";
  11. say " " ~ %grade.grep(*.value ge "E")».key.join(', ');
  12.  
  13. say "Distribution of grades by letter:";
  14. say " {.key}: {+.value} student{"s" if .value != 1}"
  15. for %grade.classify(*.value.comb[0]).sort(*.key);
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
===SORRY!===
Unsupported use of - as character range;in Perl 6 please use .. at line 4, near "]>?) $/ or"
stdout
Standard output is empty