I spent an inordinate amount of time this weekend rewriting BML's parser for speed.
A half dozen rewrites later, after squeezing out 3% more performance, then 6%, then 12%, then 24%, it's now ~44% faster, and I'm calling it quits. I wasted enough time already.
perldoc perlre is awesome. I'd never read it all word for word until yesterday, and I now feel so enlightened with things like independent matches (?>...) and negative look-ahead assertions (?!...). Not to mention (??{ code }). I look forward to Perl6 Rules.
Anyway, check out this monstrocity:
http://cvs.danga.com/browse.cgi/bml/lib/Apache/BML.pm?rev=1.40
Search for "sub bml_decode" and revel in its power.