bcrowell has asked for the wisdom of the Perl Monks concerning the following question:
?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
then the second x()'s definition overrides the first one's.sub a { sub x {} } sub b { sub x {} }
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()?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: my sub ?
by shotgunefx (Parson) on Mar 25, 2002 at 19:51 UTC | |
Re: my sub ?
by chromatic (Archbishop) on Mar 25, 2002 at 19:53 UTC | |
Re: my sub ?
by maverick (Curate) on Mar 25, 2002 at 19:57 UTC | |
by shotgunefx (Parson) on Mar 25, 2002 at 20:00 UTC | |
by maverick (Curate) on Mar 25, 2002 at 20:06 UTC | |
by Fletch (Bishop) on Mar 25, 2002 at 20:09 UTC | |
by shotgunefx (Parson) on Mar 25, 2002 at 20:12 UTC | |
Re: my sub ?
by broquaint (Abbot) on Mar 25, 2002 at 20:02 UTC | |
Re: my sub ?
by Anonymous Monk on Mar 25, 2002 at 20:35 UTC |