Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Optimization for readability and speed (code)by Masem (Monsignor) |
on Apr 30, 2001 at 22:41 UTC ( [id://76703]=note: print w/replies, xml ) | Need Help?? |
<insert all of merlyn's comments here>. In addition to sticking to the RE, given the situation that you need to allow others to maintain this code, I would include in your comments the output of OGRE or some other such tool that english-fies the regex for non native regex speakers.
Also, I would try to make sure that you grab as much as you can from the regex even if your code now does not currently need it. Say that you have a 5 field line, separated by white space, and your app currently needs only 4 of the 5 fields. I would still declare and grab all 5 fields, with commenting describing what the field is given the input format. This way, if it needs to be modified down the road to use the 5th field, they simply need to start *after* the regex, instead of possibly messing up the regex and causing the other 4 fields to be inaccessible.
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
In Section
Seekers of Perl Wisdom
|
|