use strict; use warnings; use 5.012; #for say() my $text = "Enter Iago, Othello, and others"; while ($text =~ / \s+ #A space one or more times ( #Start of $1 [^,]+ #Not a comma, one or more times ) #End of $1 , #A comma /gxms #(g)lobal matching plus standard xms ) { say $1; } --output:-- Iago Othello