Hello
iamnewbie and welcome to the monastery and to wonderful world of Perl
Without enter in the merit of what are you trying to do, the basic question is: how can i interupt a loop every
n iteration? use a counter. you can profit of the
redo function and more generally speaking of the
loop control. Search also
ModernPerl for loop control
(is here..).
Follow what this oneliner does:
perl -e "@list=(1..7);$counter=0; foreach $it (@list){if ($counter >=
+3){print qq(\n\n);$counter = 0; redo}print qq($it\n); $counter++}"
1
2
3
4
5
6
7
Your case is more complicated because there is there also the port to be associated. But you'll do on your own.
That said i think is not the best strategy: a subroutine will be better and easier: the sub receive as input the port and address list, if that list is bigger than 50, it compose the command shifting the first 50 elements and recall itself with the same port and the remaining list, like (just a draft)
sub proces_no_more_than_50 {
my($port,@addresses)=@_;
if ($#addresses >= 50) {
&execute( $port, map {shift @addresses} 1..50 );
}
else{ &execute($port, @addresses); undef @addresses;}
&proces_no_more_than_50($port,@addresses) if defined $addresses[0];
}
HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
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.