I'm in the process of learning Perl (5.8) in my spare time and as a mental (and spiritual) excercise I am attempting to design a regular expression that will enable me to convert raw "METAR" weather reports into something that is more human readable.
I know how to do the legwork to make this possible... but I have a question about efficiency.
I'm breaking this task down into sections. For each section I am using "named capture" to cache each important value to a variable. This works nicely. But due to the (very) complex nature of the METAR standard, I am forced to use many levels of nested grouping.
So my question is, can I speed up the following...
m/((xxxxxxxx)(yyyyyyyy)(zzzzzzzz))/
...by using "non-capturing parentheses" for the groups below the outer nesting level?...
m/((?:xxxxxxxx)(?:yyyyyyyy)(?:zzzzzzzz))/
I've reduced my problem down to basic principles as best I can. As I understand it, the outer parentheses will still capture everything inside.
So, is that second regex pattern more efficient than the first?
I would benchmark this myself normally, but I'm only about 20% of the way through designing the entire regex for METAR codes and I don't want to go too far down "the wrong path" if you see what I mean.
Advice gratefully received.
Wossy. :)
ps. METAR codes specification: (
http://www.ofcm.gov/fmh-1/fmh1.htm see chapter 12 if you're interested, although the entire document is very interesting in itself).
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.