Skip to content

Instantly share code, notes, and snippets.

@Zitrax
Created October 9, 2012 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zitrax/3857270 to your computer and use it in GitHub Desktop.
Save Zitrax/3857270 to your computer and use it in GitHub Desktop.
Find unused perl functions
#!/bin/bash
# Note this requires git compiled with USE_LIBPCRE
# to be able to use -P to git grep.
# And currently for some reason the regexp causes a segmentation fault
# when searching for some functions.
NCORES=`grep -c ^processor /proc/cpuinfo`
ack-grep -h --output='$1' '^\s*sub\s+(\w+)\b' . \
| sort -u \
| xargs -n 1 -P $NCORES -I '{}' sh -c "git grep -c -w -F -P '{}(?=([^\"]*\"[^\"]*\")*[^\"]*$)' \
| awk -F: '{t+=\$2} END{if(t<2) print \"{}\"}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment