Raku Books / Perl 6 at a Glance / Code Organization / Subroutines, or subs
Nested subs
Nested subs are allowed in Perl 6.
sub cube($x) {
sub square($x) {
return $x * $x;
}
return $x * square($x);
}
say cube(3); # 27The name of the inner sub square is only visible within
the body of the outer sub cube.