Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Creating dynamic variables

by tobyink (Abbot)
on Jan 03, 2013 at 15:06 UTC ( #1011467=note: print w/replies, xml ) Need Help??


in reply to Creating dynamic variables

This is about the closest I could get...

use strict; use warnings; BEGIN { package JIT; # Just In Time evaluation $INC{'JIT.pm'} = __FILE__; use base 'Exporter'; our @EXPORT = 'jit'; sub jit (&) { bless $_[0] } use overload q[""] => 'evaluate', q[0+] => 'evaluate', q[bool] => 'evaluate', fallback => 1; sub evaluate { $_[0]->() } }; use JIT; my $foo = "hello"; my $y; # needs to be declared, but we haven't assigned a value to it +yet. my $x = jit { "$foo".$y }; # $y is not yet defined. $y = "world"; # now define $y print $x;
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://1011467]
help
Chatterbox?
[chacham]: android studio is such a pain
[Corion]: I found Android Studio quite nice as a Java IDE, but then, I didn't try anything serious with it
[chacham]: it is a nice ide. its just that upgrading it always causes issues with mismatched versions of whatever
[Corion]: chacham: Oh, yes, reinstalling all the SDK versions and Gradle and whatnot, yes, even in the short time I used it (2 weeks?) I felt that pain

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2017-03-29 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (344 votes). Check out past polls.