Yesterday I was (re-)refactoring some old code. My tests ran OK, so I was about to check the thing back in, when I decided to eyeball it one more time. To my surprise, I noticed I'd removed the last reference to a sub (in other words, it wasn't getting called from anywhere), and hadn't received any notice or warning, even though I was using strict and warnings.
I realized the warning I was thinking of is for "variable appears only once", not "sub appears only once". I went looking thru the docs to see if there was some way to coax Perl into telling me that I had dead code, but didn't find one. Searching through the monastery proved fruitless as well. The B::Lint module sounded promising, but it doesn't want to run on my box, and the docs don't mention catching this type of oversight anyway. This sounds so simple, I'm sure I'm overlooking something obvious.
So, fellow monks, how do I make Perl tell me I've got a sub that is not being referenced anywhere else in the program? Just a simple compile-time check would be plenty. It doesn't have to be bulletproof; some reasonably good hints would be OK.