VSarkiss has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Warnings for unused subs
by Abigail-II (Bishop) on Jul 25, 2002 at 15:40 UTC | |
by VSarkiss (Monsignor) on Jul 25, 2002 at 15:51 UTC | |
by Abigail-II (Bishop) on Jul 25, 2002 at 15:57 UTC | |
|
Re: Warnings for unused subs
by FoxtrotUniform (Prior) on Jul 25, 2002 at 15:51 UTC | |
|
Re: Warnings for unused subs
by danger (Priest) on Jul 25, 2002 at 16:52 UTC | |
|
Re: Warnings for unused subs? here's find_unused_subs.pl!
by dada (Chaplain) on Jul 26, 2002 at 10:12 UTC |