eval { ... your code goes here ... 1; } or do { my $err = $@ || "Unknown error"; ... error handling ... };