in reply to confusing number of elements in an array

Your output loop uses $index, and you set $index=0 after your calls to sorter. If you want the actual contents of your array without $index, you can do that this way:

foreach my $seq ( @allSeq ) { print "seq -->$seq\n"; }

I suggest also that you use warnings and that you name the parameters to your subs:

sub sorter { my ( $line, $iter_sub, $inc_sub ) = @_; my $i = $iter_sub->($index); $allSeq[$i] .= $line; $index = $inc_sub->($index); print "in: $line\n"; }