in reply to Unwanted empty value in array after Splitting a string
The only exemption is the pattern split(' ',$str) so just add a grepSplits the string EXPR into a list of strings and returns that list. By default, empty leading fields are preserved, and empty trailing ones are deleted.
perl -MData::Dumper -e ' $str = "GTGNNTNNG"; @nseg = split(/[ATCG]+/,$str); @nseg = grep {/./} @nseg; print Dumper \@nseg;'
|
|---|