laziness, impatience, and hubris | |
PerlMonks |
How best to identify & Categorize Source Code?by Zadeh (Beadle) |
on Mar 31, 2008 at 22:19 UTC ( [id://677653]=perlquestion: print w/replies, xml ) | Need Help?? |
Zadeh has asked for the wisdom of the Perl Monks concerning the following question:
As an ad-hoc method, it's been common in some perl apps I use to maintain an ever-larger list of extensions (.c, .cpp, .h, .pl, ...) to recognize if a file is source code. I can think of a number of problems with this approach:
1) All files have to have an extension. It's not uncommon for people to save scripts and makefiles without one. 2) There's an implicit assumption that there is a one-to-one mapping between each unique extension and the kind of content it should have. 3) You have to continually maintain a list of these extensions. There's got to be a better way. From within *nix I might often do something like this
and then see:
This brings me to some more questions: Is there a nice tidy perl module to accomplish this effect? If not, how best to implement it?
Back to
Seekers of Perl Wisdom
|
|