use strict; use warnings; use Text::ParseWords; use Data::Dumper; my $marked = 'Jack and Jill went #up the hill# to fetch a #pail of water#.'; $marked =~ s/#/"/g; my @words = shellwords($marked); print Dumper(\@words); __END__ $VAR1 = [ 'Jack', 'and', 'Jill', 'went', 'up the hill', 'to', 'fetch', 'a', 'pail of water.' ];