Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: using eval or equivalent to automatically generate my statements

by ISAI student (Scribe)
on Dec 14, 2012 at 07:13 UTC ( #1008785=note: print w/ replies, xml ) Need Help??


in reply to Re: using eval or equivalent to automatically generate my statements
in thread using eval or equivalent to automatically generate my statements

Thank you for all yor help. Unofortunaely, I was granted very short time to do a rather thankless task. Theoretically, scratching it and start anew is the way to go. I have no management green light to do so, and the decision is not without reason. It took > 5 years of on-going user feedback to get where we wanted.

I was hoping to see some really cool PERL magic, it may be for the best, but it would have been one cool metaprogramming feat...


Comment on Re^2: using eval or equivalent to automatically generate my statements
Re^3: using eval or equivalent to automatically generate my statements
by tobyink (Abbot) on Dec 14, 2012 at 10:22 UTC

    OK, so as not to disappoint...

    Introducing Acme::Asplode: it lets you drag your caller's lexical variables kicking and screaming into your sub. Ought to work in Perl 5.12+.

    Example usage...

    use 5.012; use strict; use warnings; use Acme::Asplode; sub bar { asplode($x, $y); # steal lexical variables from our caller! say $x; say $y; asplode @A, $z; # steal moar lexicals!!! say $z; $z++; # alter our caller's lexical variable!! say for @A; }; sub foo { my $x = 1; my $y = 2; my $z = 3; my @A = qw(a b c); bar(); say "Z is changed: $z"; } foo();

    Update: Acme::Asplode, renamed Acme::Lexical::Thief is now on CPAN.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (17)
As of 2015-07-06 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (82 votes), past polls