It's a very practical concern. Sure you are perfect and will never modify it, but you've got to think about the inevitable slack-jawed yokel maintenance programmer that will follow you. Three years hence, Cletus is going to bollix things up bad because he can modify it.

It's like the story (probably apocryphal; I want to say I heard it back in college in a compilers class) of the early Fortran compiler that allowed constants on the left hand side of an assignment to be modified, changing the value in the constant pool (I think it was on an architecture that didn't allow immediate values; everything had to be loaded to registers from RAM, so even things like "1" and "4.20" were sitting somewhere in memory). Sure nobody will be silly enough to intentionally set 3 = 2, but accidents can happen (c.f. Murphy) and then someone has real fun tracking down where the really large values of 1 and 1 are coming from when suddenly 1 + 1 EQ 3 is true.


In reply to Re^4: Using Constants in Perl by Fletch
in thread Using Constants in Perl by qazwart

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.