What our does is binds the package variable to lexical scope. So a
package after an our doesn't change the variable. But if you have the
our *after* the package then it will bind the correct package. So in
your eval put the package statement before our %map and you'll be
fine.
Incidentally if
On 10/29/2014 02:47 PM, Morse, Richard E.,MGH wrote:
Hi! I'm running into an odd desire, and I'm hoping someone here can at least
tell me where to look, as so far Google and DDG are not telling me what I want.
I have a bunch of modules which have the same subroutines in each. Mostly, the
code
On Oct 29, 2014, at 2:56 PM, Uri Guttman u...@stemsystems.com wrote:
hi ricky,
i am somewhat confused as to your goal. you want each sub to use a common
%map? why not have them access it directly from the base package?
Hi! There are actually three different package variables that contain
Thanks -- I see how to do this with a string eval, but I'm hoping to avoid
having to keep the functions as text strings.
If I can't find any other way, it's what I will have to fall back on, but I'm
hoping there's some way to avoid this.
Ricky
On Oct 29, 2014, at 2:56 PM, Ben Tilly
Morse, Richard E.,MGH remo...@mgh.harvard.edu writes:
I've tried various things, but from what I can understand, even with
everything declared our, the sub definition closes over the package
that it's in when defined. I've seen references to doing an `eval
(package $package; sub handle_ages {
On Oct 29, 2014, at 3:12 PM, Mike Small sma...@panix.com wrote:
What about having a method that returns a reference to your map that you
override in each of the derived classes?
e.g. ...
package PKG::_base;
sub _map { die; }
sub handle_ages { ; }
sub handle_dests
On 10/29/2014 03:07 PM, Morse, Richard E.,MGH wrote:
On Oct 29, 2014, at 2:56 PM, Uri Guttman u...@stemsystems.com wrote:
hi ricky,
i am somewhat confused as to your goal. you want each sub to use a common %map?
why not have them access it directly from the base package?
Hi! There are
In a block you can do:
no strict 'refs';
my $mapref = \%{$package\::map};
And now you have a lexical reference that will bind to a closure.
Do note that using objects here is more common.
On Wednesday, October 29, 2014, Morse, Richard E.,MGH
remo...@mgh.harvard.edu wrote:
Thanks -- I
Morse, Richard E.,MGH remo...@mgh.harvard.edu writes:
Thanks, except I'm not in an object context.
Sorry, I should read more carefully.
Well, what about if the base module's functions take the reference to
the map as an argument and your symbol table munging instead of
assigning the functions