@strings = qw(abc-def abc--def abc-d-ef abcdef ---abc--def--); for my $string (@strings) {  print "<$string> " . ($string =~ tr/-// == 1 ? "ok" : "not ok"); } => ok not ok not ok not ok <---abc--def--> not ok