>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'