use strict; use warnings; my $command = '!book this is my test book !number 1222223 !book another book"'; my @commands = split /(?=!)/, $command;