I too have a little problem with the names. Those ascending numbers lead me to conclude that the problem domain is being poorly mapped into Perl. merlyn says that you should capture regularities in code. Yes indeed, but that still doesn't validate this map { "arg$_" } approach as being a good one. A completely different approach is required. Which is why I like ignatz's idea.

Can someone post references to the thread(s) that rob_au is talking about? I seem to have missed them, and I'm not sure if I'm taking the example too literally.

One thing that I can see in favour of rob_au's initial approach is that it allows you grep the source code to find out where arg4 is used. Never underestimate the power of static analysis. If you're creating those names on the fly then you don't have that luxury.

If the project is big enough, then it may even be worth going as far as pulling those names out of the source code and storing them in a data file. That gives you a different degree of flexibility and control. You can write a Makefile to ensure that you can run a program against the data file to make sure it is stays coherent.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re:x2 On Foreach Loops and Maintainability by grinder
in thread On Foreach Loops and Maintainability by rob_au

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.