You can't check if the glob contains a code reference before you make sure you have a glob in the first place!
But this is all moot. This solution doesn't work as of Perl 5.22. You should be using one of the solutions that work in 5.22 and beyond. See Re^4: accessing stashes