sub parse($s) { with $s.lines.map(*.comb(/<[0..9_]>/).cache) { fail "Lines of different length" if .map(+*).unique >= 2; return .map(*.comb(3)); } } dd parse("123123123");