in reply to Search and Extract from String

Untrue assumption in the last "#" note:

" ...
#Split the remaining string by space.
#check if last word is "-". If it is, extract the second last word,which will be "design".
"

Test case:

perl -E "my $s = 'This is a design-controlled'; my @arr=split / /, $s; for $_(@arr) { say $_;}"

Output (note that last word is NOT a stand-alone hyphen/dash):

This is a design-controlled

And the "second last word" is "a"


If you didn't program your executable by toggling in binary, it wasn't really programming!