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


in reply to Seeking a better way to do it

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

Given a string: Enter Iago, Othello, and others I want to extract "Iago" and "Othello" to a data structure.

No data structure :(. Reputation--.