Piers Cawley pointed out:
I think you could probably get away without the .kv there since, in a%a_students = grep {.key ~~ :i/^a/}, %grades.kv;
list context you're going to get a list of pairs anyway.
In fact, the code is invalid as it stands. The following variations work as desired:
%a_students = grep {.key ~~ /:i^a/} %grades; or: %a_students = grep {.key ~~ m:i/^a/} %grades; or: %a_students = grep sub($k,$v){$k ~~ m:i/^a/}, %grades.kv; Damian