1.) Do you find /x regexes easier to read/understand, or harder?
Easier to understand, harder to read, and harder to mod. I have found that if a regexp is complex enuff to warrant in line commenting then the inline commenting makes reading the expression
itself too damn difficult. The danger IMHO is that you write a regexp
then comment it with /x and in effect ensure that the code cannot be changed without removing the comments. I must confess I tend to not use /x I tend to place a comment block above the regexp and paraphrase complex regexp in that.
2.) Does this "ease of reading" change one way or the other as you gain experience with regexes?
I think that regexp cant be read at all like regular code (or at least I cant). When reading code I have long since stopped seeing the specific commands and instead look at the flow and interpolate. Just as when reading english I dont think I see all the words my brain just rushes over them filling in the details later. With regexps there seems to be no easy way to do this. I just sit down and read them statement by statement backfilling as required. It gets quicker, because I dont need to refer to a manual now *grins*.
3.) What kinds of rules should be followed when using /x to ensure the best readability?
Personally I dont use them at all often, the only time I would has already been listed in the thread, that being to break up regexp's that > 80 chars. I get quite cross if any code line is > 80 chars.
--
Zigster
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.