Is there any way to do the equivalent of
my sub foo {}
?
In other words, I want a subroutine within a subroutine that is invisible to every other subroutine in the same package. Specifically, I have a one-line helper routine that I'd like to have with the same name within many parent subroutines, using slight variations in each one. But if I do
sub a {
sub x {}
}
sub b {
sub x {}
}
then the second x()'s definition overrides the first one's.
Is the best way to do this by just having a subroutine reference at the package level, and assigning anonymous subroutines into it from inside a() and b()?