do{ my @a; push @a, $x; for(my $i=0;$i<$x;$i++){ #for each sector for(my $j=0;$j<$numFngs;$j++){ push @b, $obj->{sectors}->{$sector}->{$j}->{c2i}; } push @a, @b; } $x=update($x); }while (certain event to end);