if (some_condition){ *custom_method = sub { do whatever you want }; }