To address that specific example, if you re-wrote it as a subroutine, you could just
return and be done with it. There is no need for a
last LABEL when you do something like that.
sub foo
{
my ($ary1, $ary2) = @_;
foreach my $wid (@$ary1)
{
foreach my $jet (@$ary2)
{
last if ($wid > $jet);
$wid += $jet;
}
}
return;
}
foo(\@ary1, \@ary2);
Sure, you can use LABELs to reduce what I might term "flag variables", or variables that merely represent a condition, but with a little re-engineering, you can usually eliminate those and still not use LABELs.
Update:
I had put a
return if ($wid > $jet); but this was incorrect, and this would explain why my remarks seem kind of incoherent.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.