Even then there are two major issues to my mind:

  1. The clutter around the assignment hides the assignment making it harder to see where the variable gets its value
  2. It is easy to confuse = and == so using the assignment operator in a conditional expression makes code harder to maintain

Point 2 is seen as sufficient of an issue that many compilers generate warnings for assignment in conditional expressions. I love the way that Perl allows terse functional chords that allow the equivalent of many lines of code in other languages to be wrapped up in a single compact statement. But playing tricks with side effects just to save a line of code doesn't sit well with me.

I'm completely fine with the equivalent assignment in a while statement though - go figure.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

In reply to Re^4: scope of variables in a sub by GrandFather
in thread scope of variables in a sub by frontrange

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.