I missed the 'triple nested labeled goto spaghetti loop' and wound up voting for the simply uninteresting 'labeled block'. My reasoning behind wanting the triple nested goto block is simple enough: if I'm going to be using the construct for the short eternity of my life, I'd better enjoy using it. Just reming yourself that you are going to drive yourself crazy using one looping mechanism, so you'd might as well choose the crazy one.
# why code this (equiv: print $_, "\n" for 1 .. 10;)
for my $i (1 .. 10) {
print $i, "\n";
}
# when you can code this? -- untested, no perl
# on current box; probably doesn't do what
# the above snippet does, but it's suppose to
my $i = 0;
ONE:
{
$i -= (8 - 2 * 2 - 2 * 4); # $i += 4
goto FOUR;
TWO:
{
print $i;
THREE:
{
print "\n";
10 == $i ? exit() : goto ONE;
FOUR:
{
$i += 3 * -1; # $i -= 3;
goto TWO;
}
}
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|