A rule is usually a summary of a lot of experience; it explains the common cases, not the edge cases.

For example, "don't parse HTML with regexps" is a good idea in general: you can't do a good job of parsing arbitrary HTML with a regular expression.

On the other hand, if you wrote all the HTML yourself, and know exactly what applying a given regexp will do to your HTML, then go ahead and use the regexp if it does exactly what you want.

If you didn't write the HTML, on the other hand, you probably can't reliably predict what a given regexp will do to the meaning of a page. You might need to carefully parse the HTML, determine carefully what sections are which, and only then make your substitution. This is the safer assumption: and so the rule prevents you from making bad assumptions without knowing what you're doing.

Understanding the summary is a good idea; understanding the full history of why that summary was written is even better. You'll learn why the rule was made, who thought it was a good idea, in what context and to what extent to apply it, what the risks are for not following the rule, and when it doesn't make sense to apply the rule at all.

For example, hurricane insurance is often a good idea. But this rule works much better for people living in New Orleans than it does for, say, people living in the Nevada desert.


In reply to Re: Breaking The Rules by Anonymous Monk
in thread Breaking The Rules by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.