BEGIN { eval "sub foo {}" if rand() < 0.5; } foo(); #### if (rand() < 0.5) { 1 while 1; } #### BEGIN { my $x = "... arbitrary perl code ..."; eval "sub foo {}" if eval $x; } foo();