in reply to Re^3: Limit loop
in thread Limit loop

Before the loop remove the excess elements

splice @favs, 25; foreach (@favs){

Replies are listed 'Best First'.
Re^5: Limit loop
by AnomalousMonk (Archbishop) on Aug 31, 2022 at 19:18 UTC
    splice @favs, 25;

    Note that splice-ing past the end of the array results in a warning in earlier Perl versions:

    Win8 Strawberry 5.8.9.5 (32) Wed 08/31/2022 15:05:47 C:\@Work\Perl\monks >perl -wMstrict -MData::Dump=dd -le "my @ra = ('a' .. 'd'); splice @r +a, 10; dd \@ra" splice() offset past end of array at -e line 1. ["a" .. "d"]
    (I don't know with what version this warning was suppressed.)


    Give a man a fish:  <%-{-{-{-<