I'm not really sure that comparing the stringified values of controller objects can be considered kosher. Perhaps you could compare the values of action_namespace called on the controllers, or simply change your logic to use $c->req->path instead of $c->controller?