cool tutorial and why to think before you use a regex

TeeJay on 2002-10-17T13:45:25

http://www.neuralust.com/user/mingdocs/lessons/graph-bars/tutorial2.php

3d bar charts in flash using ming.

In other news - regex's aren't always the best way to parse stuff - most of the time its quickest to use split and then work on smaller simper chunks.


Subversive Regex

Dom2 on 2002-10-17T14:03:17

Split is a subversive use of a regex though... Really, you meant to use Parse::RecDescent, right? :-)

-Dom

Re:Subversive Regex

TeeJay on 2002-10-17T14:10:15

Yes

I mean its often better to attack a problem with tr, split, etc rather than building a regex to solve a problem thats already solved by a pattern based function, even using a glob or some other function.

Of course if there is a module that parses something better - be is Parse::Excel, DBD::CSV or Parse::RecDescent (eeek! grammars!!) then we should use those.

I was just surprised that I wrote a huge and awkward regex to parse lines of IIS logs when they were a space seperated list with a handy dandy comment line naming each element so with two simple splits and a couple of arrays it is possible to handle different formatted logs and always access the fields you want without worrying about the regex which seemed like a good idea to start with. KISS leads to more KISS.