Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Limit loop

by johngg (Canon)
on Aug 30, 2022 at 21:59 UTC ( #11146520=note: print w/replies, xml ) Need Help??


in reply to Limit loop

Truncate the @favs array before entering the loop if it has more than 25 elements. Setting $#favs to 24 is setting the index of the last element so that the array now has 25 elements, 0 through 24.

johngg@shiraz ~ % perl -Mstrict -Mwarnings -E ' my @favs = ( q{a} .. q{z} ); say qq{@favs}; $#favs = 24 if scalar @favs > 25; say qq{@favs};' a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146520]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2023-01-31 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?