The problem is actually in your
unless clause. According to the docs for
defined, the way to tell if a subroutine is defined is to simply call
defined(&SOMETHING). Putting the backslash in front of it will actually cause it to return a valid (non-undef) reference value, albeit to an undefined subroutine.