in reply to Re: Write code using less lines
in thread Write code using less lines
You can save a little typing and also be a little more comprehensive with respect to "anything not a dash" by using the c flag (complement) of tr, see Quote and Quote like Operators.
knoppix@Microknoppix:~$ perl -E ' > $str = q{ABC---DR----EEEEEGGGG-GRE-RED----KKKK---}; > $len_seq = $str =~ tr{-}{}c; > say $len_seq;' 24 knoppix@Microknoppix:~$
I hope this is of interest.
Cheers,
JohnGG
|
|---|