in reply to Re^7: How to simulate a preprocessor macro without one?
in thread How to simulate a preprocessor macro without one?
Now I see that my question directed the issue in the wrong direction. Actually I needed two separate tools. One tool for accessing lexical variables from the caller and an another tool to simplify the resulting code after the first problem is solved.
This is the idea how the template program peeks inside the callers variables.
Now - only the second problem needs to be solved. How to write template( sub{eval(shift)} ); somehow shorter way?sub template { my $uplevel = shift; $uplevel->('print $x;'); $uplevel->('print $y;'); } my $x = 'X'; for my $y (1 .. 3) { template( sub{eval(shift)} ); };
|
|---|