Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: Implementing a cyclic array

by ramlight (Friar)
on Jun 19, 2009 at 13:28 UTC ( #773032=note: print w/replies, xml ) Need Help??

in reply to Re^2: Implementing a cyclic array
in thread Implementing a cyclic array

While many of the other solutions are perhaps a closer fit to your problem, I thought that I would show you a solution that is closer to the code that you tried:
use strict; use warnings; my @array_1 = ("tom","harry","diana","nick","sally","henry"); my @array_2 = ("play()","eat()","sleep()"); foreach (@array_1) { my $action = shift(@array_2); print "$action maps to $_\n"; push(@array_2, $action); } which prints play() maps to tom eat() maps to harry sleep() maps to diana play() maps to nick eat() maps to sally sleep() maps to henry

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-09-29 23:45 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.