Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Limit loop

by jwkrahn (Monsignor)
on Aug 30, 2022 at 21:57 UTC ( #11146519=note: print w/replies, xml ) Need Help??


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:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2023-06-08 06:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?