my $reg=shift; my $top=@$reg; print "START OF\n"; for(my $i=0;$i<=$top;$i++) #### for my $data (@$reg) { ... }