http://www.perlmonks.org?node_id=1070788


in reply to Splitting only on internal pattern, not at start or end of string

The pattern for split isn't terribly complicated either:

my @contigs = split /(?<=[^N])N++\B/, $sequence{$key};
Update: /[^N]\KN++\B/ with a \K will also work, as long as you don't capture the gaps.