Keep It Simple, Stupid | |
PerlMonks |
heuristic to detect (perl) codeby LanX (Saint) |
on Jan 19, 2013 at 08:28 UTC ( [id://1014182]=perlquestion: print w/replies, xml ) | Need Help?? |
LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi I'm meditating about a regex based heuristic to roughly detect if a text paragraph (multilines delimited by '\n\n') is rather perl source code than normal text. The best idea I had so far was: using regexes to count the line endings with ';' or '}' possibly followed with a '#' part. Another to check the frequency of words starting with a sigil. I'm not talking about a valid parser, just a fuzzy detector. Any better ideas? One use case could be a JS that checks the contents of a posting in the monastery and warns about missing <code> tags, offering to include them. (I'm a bit tired of unreadable posts here, and all the following edit-considerations and replies)
Cheers Rolf PS: I'm not sure if this thread better belongs to PM-Discussions.
Update
Other ideas:
Interesting links
Back to
Seekers of Perl Wisdom
|
|