use Data::Dumper; my $foo = 'one,123,a s d f,a,b,c,bad,e,f,g,h'; my @first = split(',',$foo,4); my @rest = split(',',pop @first); print Dumper \@first, \@rest; for (0..$#rest) { die "index $_ is bad: '$rest[$_]'" if length($rest[$_]) != 1; }