my @strings = qw( a?1 a?2 a%3 b?2 b?3 b%5 c%4 c%5 c?6 d%2 a?7 c?7 ); my @mandatory_types = qw( a? b% c? ); # ^^^^^^^ my $n = 5; # ^