in reply to Need help with nested for loops

my $j = $i * $g;
This is what is wrong (as explained). The nested c-style loops can produce desired output if you do it like this:
use strict; use warnings; my $group = 20; for ( my $id = 0; $id < 120; $id += $group ) { for ( my $grp = 1; $grp <= $group; $grp += 1 ) { printf "ID: %d\tGRP: %d\n", $id + $grp, $grp; } }