in reply to private subroutine in package?
Yes, but you have to call it a little differently.
package Whatever;
my $privatesub =
sub {
# blah blah blah
};
sub publicsub {
$privatesub->(arguments...);
}
Here we've made an anonymous subroutine and stored it in a private my variable. No code outside this file will be able to see the $privatesub variable, so the private subroutine is only accessible from inside the file.
Since $privatesub is actually a reference to our private subroutine, we need to use the -> notation to invoke it.
|
|---|