$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, $@); }