if ($sap_at_end) { do_something_with($end_sap); } else { ... }