in reply to sub returning undef
I both would not recommend that style, and strongly suspect that you're misunderstanding something basic about the behaviour of those functions.