while (<FH>) { s/#.*$//; my @args = split(' ', $_); next unless @args; ... process command ... }
If, however, you have any recursive syntactical elements (like begin/end grouping symbols which need to be matched), a proper parser written with Parser::RecDescent is probably in order.
In reply to Re^2: Writing a parser
by pc88mxer
in thread Writing a parser
by Zielony
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |