in reply to Generate a # between 1 and 50 in groups of 5

Turn the problem inside out: you want to print five groups of five numbers. That's the way you need to structure your nested loops.

You already have a random list of numbers so you can pull numbers off the front of the list 5 at a time using splice. So putting those together (with another small wrinkle) we get:

#!/usr/bin/perl use strict; use warnings; use List::Util 'shuffle'; my @numbers = shuffle(1 .. 50); for (1 .. 5) { my @group = splice @numbers, 0, 5; print "$_\n" for @group; print "\n"; }

The small wrinkle is the for @group "statement modifier" which is the nested loop that prints out the individual numbers in each group.

Note that to loop five time in Perl we can use for (1 .. 5) instead of the unwieldy and error prone C loop. The intent of the Perl loop is much clearer and much easier te get right.

Perl is the programming world's equivalent of English