I never said that you can't use our for the same task. I said that it was worse.

In example 1, with our it is a lot easier to make and a lot harder to catch a mistake where in one file you have declared $with_foo while in the other you've named it $for_foo. This makes our worse.

In the second example, to avoid problems you are requiring people to have a habit that most people don't have. Furthermore it is not enough to put curlies around your package declarations, you also have to put curlies around your original program. However taking that step means that if you discover that you need a small auxiliary package, you have to make a much, much bigger change. Again our is worse.

Summary: from a software engineering standpoint, in Perl 5 our is the same or worse than vars. Its only win is a slight convenience/aesthetic advantage.

(My attitude is that Perl 6, if it ever arrives in production, will be a different language that needs to be judged on its principles.)


In reply to Re^18: the "our" declaration ?!! (special vars) by tilly
in thread the "our" declaration ?!! by perlpal

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.