for (1..5) { $_ == $b ? goto JUMP : 0; } print "\$b has to be a number and is either 1, 2, 3, 4, or 5."; JUMP:

Please do not make me repent of having mentioned goto to you!!

Also, I'm fully aware of your obsession for ?: (in fact I even frontpaged that other thread, since after all a nice discussion got out of it) but then again there's no need to use it there: it's plain ugly. Do you really want to stay concise? Just use a short circuiting and:

$_ == $b and goto JUMP for 1..5;

But really: do not use goto at all, and adopt some of the other solutions others suggested, instead.

using goto won't hurt you when you just use it once... and the distance of goto and the refering label name should be as much as possible close to each other so you can keep an eye on that.

Using goto will hurt you even when you just use it once... because then you will want to use it twice, then three times and so on. And first or later you will want to insert some code between a goto and its target, because "that's not much code". And then some more, because that's still not too much", and so on. And first or later it will bite you back in the neck. And even without that, quite a lot of programmers will think you're an asshole anyway. Of course you can live with that, but... I wouldn't: there's a good reason why they would.


In reply to Re^2: Quicker way to do this IF statement 1-5 by blazar
in thread Quicker way to do this IF statement 1-5 by Anonymous Monk

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.