Using Try::Tiny 

try {
    do_something();
}
catch {
    # exception is now in $_
}
finally {
    # cleanup goes here
};