in reply to Re^2: Pushing arrays around inside a loop ;-)
in thread Pushing arrays around inside a loop ;-)

Use modulo division and you dont have to modify the arrays at all.

my @emps=map "employee_$_",1..5; my @codes='v'..'z'; my $n=3; for my $j (0..$n-1) { for my $i (0..$#emps) { print $emps[$i],":",$codes[($i+$j) % @codes],"\n"; } print "\n"; } __END__ employee_1:v employee_2:w employee_3:x employee_4:y employee_5:z employee_1:w employee_2:x employee_3:y employee_4:z employee_5:v employee_1:x employee_2:y employee_3:z employee_4:v employee_5:w
---
demerphq

Replies are listed 'Best First'.
Re^4: Pushing arrays around inside a loop ;-)
by Baratski (Acolyte) on Jan 06, 2005 at 10:29 UTC
    Hey, demerphq, that worked like a charm! Thank you so much. I made a couple of hashes to substitute your output with employee names and work areas. I'll study this modulo division that you used. I've never worked with it before.

    Thanks again to everyone that helped me out. You all are very helpful when I come here from time to time with a problem.

    -Baratski