I have to do a bit of work cleaning up some old code and I wrote this quick shell script to find possibly unused subroutines.
#!/bin/bash
tempfile=/tmp/$$allsubs.txt
ack '^\s*sub\s+(\w+)\b' lib | \
awk '/sub (\w*)/ { print $2 }' | \
cut -d'(' -f1 | \
sort | \
uniq > $tempfile
for sub in $(cat $tempfile); do
if [[ $(expr `git grep -E "\<$sub\>" |wc -l`) == 1 ]]; then
echo $sub
fi
done
rm $tempfile
My bash skills are awful (see above), but I've already found 25 subroutines that can probably be deleted. I say "probably" because all have to be investigated.
Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you.
And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/