for (qw/ ,asd asd:asd asd, asd,asd asd,,asd/){ my $test = $_; print "$test: "; print "yes" unless $test=~tr/a-zA-Z,//c or index( $test, ',') == 0 or index( $test, ',') == -1 + length( $test) or index( $test, ',,') > 0; print "\n"; }