my $rc = do($mycode); if ($@ || !defined($rc)) { if ($@) { if (ref($@) eq 'HASH') { print("Error from $mycode: $$@{'Error'}\n"); } else { print("Compilation errors in $mycode: $@"); } } else { print("Couldn't access $mycode: $!"; } }