do_a(); my::Error::register(undo_a => ARGS); if ($do_c) { do_c(); my::Error::register(undo_c => ARGS); } do_b(); my::Error::register(undo_b => ARGS);