It's not clear (at least, not to me) what you mean by "cleaning whitespace from source code". The first interpretation that comes to my mind would be something like "removing all whitespace that is not syntactically significant to the compiler/interpreter" for each progamming language in question.
If this is what you mean, there's still the question of what you want to do with comments in the source code (remove them entirely, or just normalize whitespace?); presumably, you'll need to be able to identify the beginnings and endings of quoted strings, so you can leave the enclosed whitespace as is (assuming you don't want to change the output of the program as a side effect of "cleaning" the source code). In any case, you're probably going to need something like Parse::RecDescent, which is, effectively, the perl version of "yacc".
It'll be a challenge, and I wish you luck, but once you work out how the rules are stated, and figure out the rules you need for each language, switching from one rule set to another should be pretty trivial.
If you mean something else by "cleaning whitespace", it would be hard for me to guess what that might be.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.