The reason it's so hard to read and error-prone isn't the number of sigils in my opinion; it's the amount that's variable.

These parts are fixed:

for my ___ ( ___ .. ___ ) # Perl for ( ___ ; ___ ; ___ ) # C

We can quickly identify these as counting loops, and we can quickly identify and locate the parts that define the loop. (Well, the number of sigils in the C version does make this harder, so the number of sigils is a factor, but I believe this to be a secondary factor.)

So what's left? In the Perl version, we have $i, 0 and 9. Clearly unbeatable for clarity in this trivial case. But it supports more complex cases well too.

In the C version, we have my $i = 0, $i < 10 and $i++. That's 9 tokens (when counting $i as one)!!! And all of them could vary. Is < used or <=? Maybe neither... Is my used? Is the same var used throughout? etc etc etc etc There are so many variations that the whole must be analyzed each time it's encountered.

Most of the time, the loops takes on the following shape:

for ( my ___ = ___ ; $same < ___ ; ++$same )

But variations occur too often to assume the loop takes on this shape. And it's not always easy to spot if a variation is used at glance. But we make this assumption anyway, and that's when mistakes happen. This is why it's also error-prone.

This is the same reason we use subs. We sacrifice flexibility, but we gain readability and reliability.


In reply to Re^7: 5.40 released by ikegami
in thread 5.40 released by hippo

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.