Update: Just had to make a correction for multiple matches on one line...

perl -ne 'while (/(\w*_\w*)/g) { print "$1\n";}' code_file(s)

You may want to change the regex to accept only names with a leading alpha character, or so it must contain at least one alpha character, or save the names into a hash to remove duplicates, so YMMV from what I've produced here...