Nested subs are allowed in Perl 6.
sub cube($x) {
ย ย ย sub square($x) {
ย ย ย ย ย ย ย return $x * $x;
ย ย ย }
ย ย ย return $x * square($x);
}
say cube(3); # 27
The name of the inner sub square is only visible within the body of the outer sub cube.