$ perl -E ' > $text = q{this.is.example.text}; > @items = split m{(\.)}, $text; > say for @items; > $new = do > { > local $" = q{}; > qq{[@items[ 0 .. 3 ]] [@items[ 4 .. 6 ]]}; > }; > say $new;' this . is . example . text [this.is.] [example.text] $