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


in reply to Separating array contents

Suggestion:
use 5.014; use Data::Dumper; my @arr = ('!', 'my', 'name', '!', 'is ', '!'); my $joined = join '' => map { s/^\s+|\s+$//g; $_ } @arr; $joined =~ s/^!|!$//g; my @result = split /!/ => $joined; say Dumper(@result);
This will handle the !-character in the beginning so that it won't generate an empty cell. It also trims the strings in the cells as in your description you had "is " -> "is". Update: improved trim regex