$sth->execute() || sub { ... }->(); # or $sth->execute() || &{ sub { ... } }(); # alternatively $sth->execute() || do { ... };