A program should not be pushing and shifting a pseudo-global from hundreds of locations. Code duplication like that should be avoided by making a subroutine.
Since you naturally put all those similar subroutines close to each other in the code, you can then tell when you've got a critical mass and it has become worth it to fission the code off into a "human resources" object or module.

You don't need to refactor a hundred places. You only need to touch the subs, and they are all conveniently located in one place.


PS: Personally, I always use refs unless I know for sure that the array or hash will never be passed around. Makes variables more consistent to use, and easy to pass around.

I suppose that means that I *don't* use sigils to determine the type. Instead I use the variable name itself. Singular vs plural, noun vs adjective. As far as arrays vs hashes go, I have found that there is very little overlap between "order is important" and "needs to look up specific entries by name". On the rare occasions where both are needed, it is complex enough to be worth an object and then it supports both so there is no problem.

PPS: Hopefully there is no confusion between "you can do everything as an object" vs choking TIMTOWDI by making it "you must do everything as an object".
The latter would be bad.


In reply to Re: Benefits of everything is an object? Or new sigils? by SuicideJunkie
in thread Benefits of everything is an object? Or new sigils? by LanX

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.