The Try::Tiny boilerplate 

my ( $error, $failed );

{
    local $@;

    $failed = not eval {
        # ...
        return 1;
    };

    $error = $@;
}

if ( $failed ) {
    warn "got error: $error";
}