$code = "print 'Hello World.'"; $sub = eval "sub { $code }"; unless ($sub) { # ack! it failed to eval # lets leave a note about the code, and the error # so we can debug this. die sprintf('CODE: %s\n\nERROR: %s\n\n', $code, $@); }
In reply to Re^2: Creating subroutines on the fly
by cowboy
in thread Creating subroutines on the fly
by pander
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |