The inner while is useless, because after the first iteration it will always leave the inner while. You could write it this way instead:
for (3 .. 8) { my $pdu_num = $_; $pdu_num = 11 - $pdu_num unless defined $order; if (@nodes) { my $node = shift @nodes; $map{$node} = $pdu . '['.$pdu_num.']'; next; } }
Now you don't have nested loops anymore, so you don't need the label for next. (Actually you don't need the next at all, because it's the last statement in that loop)
Update: another slightly improved version:
for (3 .. 8) { my $pdu_num = $_; $pdu_num = 11 - $pdu_num unless defined $order; last unless @nodes; my $node = shift @nodes; $map{$node} = $pdu . '['.$pdu_num.']'; }
In reply to Re: More effective way to increase two elements of a list in parallel?
by moritz
in thread More effective way to increase two elements of a list in parallel?
by et_alia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |