Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Is there a "better" way to cycle an array?

by choroba (Chancellor)
on Sep 07, 2013 at 19:21 UTC ( #1052839=note: print w/replies, xml ) Need Help??


in reply to Is there a "better" way to cycle an array?

You can use the modulo operator:
for my $i (0 .. 29) { print $stuff->[ $i % @$stuff ]; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052839]
help
Chatterbox?
Discipulus ...
choroba . o O ( getting old )
[holli]: I liked red coke. ensures a hell of a hangover though
[Corion]: Naah, there is good wine, and I like its taste. I also like beer, depending on the food that goes with it :)
[holli]: but really, there are a lot of myths around wine. starting with people thinking they could distinguish red and white wine by taste (when blindfolded) let alone australian and french red win
[holli]: that's an empirical fact btw

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2017-09-25 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?