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
|
---|
In Section
Seekers of Perl Wisdom