I'm currently reviewing someone elses code, and have come across this little gem
foreach my $enum( @$enums) { return 1 if ( $check_type eq $enum); }

now, I want to throw this back for a little bit more work, cos it just looks wrong. I don't like the fact that it just leaves the loop hanging in mid-air.

But I need a wee bit more ammo than simply "I don't like it". Is there anything actually "bad" about doing this? Or am I just being fussy?
UPDATE: Wow! I expected a lot more support for my way of thinking - I stand corrected, and will now go back and eat humble pie.

Thanks, Monks. Anonymous Monk, I shall pass your code on to my reviewee. :)

In reply to "return" to break out of a loop by weedom

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.