in reply to Re: How to simulate a preprocessor macro without one?
in thread How to simulate a preprocessor macro without one?
I have studied this issue a little more. I found that practically I do not need an ordinary (source manipulating) macro function at this case. In my case I need an access to the lexical scope of the callers environment to eval string type closures as they would exist inside the callers code.
Is there any practical method to change the lexical scope temporarily? caller() will give you some access to the callers properties but I think I need more.
sub foo { my $name="FOO"; bar("$name"); } sub bar { my $name="BAR"; print "My name is $name"; #My name is BAR function_to_do_something_using_callers_lexical_view { print "Your name is $name"; #Your name is FOO } } foo();
If there is no such function, as I fear, would it be "easy" or even possible to make a plugin which could install this kind of new core function to the interpreter? Or should I make my own Perl release ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to simulate a preprocessor macro without one?
by LanX (Saint) on Feb 09, 2010 at 12:34 UTC | |
by AriSoft (Sexton) on Feb 09, 2010 at 15:57 UTC | |
by LanX (Saint) on Feb 09, 2010 at 17:23 UTC | |
by ikegami (Patriarch) on Feb 09, 2010 at 18:14 UTC | |
by AriSoft (Sexton) on Feb 09, 2010 at 21:47 UTC | |
by LanX (Saint) on Feb 09, 2010 at 22:06 UTC | |
|