htmanning has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I have a database field called favorites with 3 pieces of information. Each favorite is separated by 3 tildes like this~~~. I loop through and pull out a number to set to a string like this:
A few of these favorite fields have more than 25 favs in them, and I want to limit the number that go into $favnums to 25. How do I stop the loop when I hit 25 and just ignore the rest?@favs = split /~~~/,$favorites; $favnum = ""; foreach (@favs){ ($favtitle,$favlink,$favnum) = split /\|\|\|/,$_; $favnums=$favnum . "," . $favnums; } #end foreach (@favs){
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Limit loop
by pryrt (Abbot) on Aug 30, 2022 at 20:10 UTC | |
by pryrt (Abbot) on Aug 30, 2022 at 21:55 UTC | |
Re: Limit loop
by johngg (Canon) on Aug 30, 2022 at 21:59 UTC | |
Re: Limit loop
by NERDVANA (Deacon) on Aug 31, 2022 at 17:17 UTC | |
by htmanning (Friar) on Aug 31, 2022 at 19:39 UTC | |
Re: Limit loop
by tybalt89 (Monsignor) on Aug 30, 2022 at 22:13 UTC | |
by htmanning (Friar) on Aug 30, 2022 at 23:02 UTC | |
by Marshall (Canon) on Aug 31, 2022 at 05:53 UTC | |
by htmanning (Friar) on Aug 31, 2022 at 19:39 UTC | |
by hippo (Bishop) on Aug 31, 2022 at 08:30 UTC | |
Re: Limit loop
by jwkrahn (Abbot) on Aug 30, 2022 at 20:42 UTC | |
by pryrt (Abbot) on Aug 30, 2022 at 20:59 UTC | |
by htmanning (Friar) on Aug 30, 2022 at 21:10 UTC | |
by pryrt (Abbot) on Aug 30, 2022 at 21:44 UTC | |
by jwkrahn (Abbot) on Aug 30, 2022 at 21:57 UTC | |
by AnomalousMonk (Archbishop) on Aug 31, 2022 at 19:18 UTC |
Back to
Seekers of Perl Wisdom