- or download this
my $hyphens = 0;
$hyphens++ while $str =~ /-/g;
- or download this
my $hyphens = length $1 if $str =~ m{\A(-*)};
- or download this
$ perl -Mstrict -Mwarnings -le '
> my @strings = qw{--aacgtACG ctgGTTAtga};
...
--aacgtACG - 2
ctgGTTAtga - 0
$