No, it seems (mostly) to be the job as intended. The following code:
use strict; use warnings; $_="GGGGG-SOMETHING-ELSE-GGG-LAST"; my @a=split(/G{2,}/,$_); print join(",",@a) . "\n";
outputs the result:
,-SOMETHING-ELSE-,-LAST
The problem is that the first element of the empty string exists. So, to fix this, you can do something like:
use strict; use warnings; $_="GGGGG-SOMETHING-ELSE-GGG-LAST"; my @a=grep{$_ ne ""}(split(/G{2,}/,$_)); print join(",",@a) . "\n";
And this creates what you want:
-SOMETHING-ELSE-,-LAST
user554546
source share