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;