in reply to Analyse an array and join only some elements of it

>perl -wMstrict -le "use List::MoreUtils qw(part); ;; my @strings = qw(X XY AAA WXYZ VWXYZ BBBCCC TUVWXYZ); ;; use constant { X3 => 0, NX3 => 1, }; my @indices = part { length($strings[$_]) % 3 ? NX3 : X3 } 0 .. $#strings; ;; print qq{indices of strings whose lengths are...}; print qq{ even multiples of 3: @{$indices[X3]}}; print qq{ non-even multiples of 3: @{$indices[NX3]}}; ;; my $aminos = join '', @strings[ @{$indices[X3]} ]; print qq{amino acids: '$aminos'}; " indices of strings whose lengths are... even multiples of 3: 2 5 non-even multiples of 3: 0 1 3 4 6 amino acids: 'AAABBBCCC'

From the OP:

... Found x blocks (x = number of elemens in the array = $#array) ...

$#array is the highest index of an element in the array. The number of elements would be given by  scalar(@array) or, in general, by evaluating  @array in scalar context, e.g.,  0+@array or  @array == 3 or some such.