Most esteemed monks, I seek your wisdom in finding a more elegant solution to a problem I'm working on. Given a string:
I want to extract "Iago" and "Othello" to a data structure. My solution is as follows:
use strict;
use warnings;
# I'm actually reading this from another source, but am hand codin
+g
# the string here for demonstration purposes.
my $char_list = "Iago, Othello, and others";
my @words = split /\W/, $char_list;
foreach my $word (@words) {
if ($word =~ m/[A-Z]\w+/) {
my @entering_chars;
push @entering_chars, $word;
}
}
My present solution works, but it seems like I'm taking a lot of unnecessary steps to get there. If anyone would care to explain how to do this with a regex, or some other method less dependent on a loop, I would much appreciate it.
Update: correction. I'm not looking to capture "Enter," but it's also been split off from the string by the time I get here.