unless( my $error = foo() ){ # do some stuff }else{ warn "whoops, foo() failed, error code: $error\n"; }