in reply to Re^3: next if attempt
in thread next if attempt

length is an extremely cheap operation, so an ST is superfluous clutter here. The full-words-only effect does not require an extra map either - just stick the assertions around the final regex.
my $stopmatch = join '|', sort { length $b <=> length $a } qw(car pet carpet); $stopmatch = qr/\b(?:$stopmatch)\b/;
Note that sorting on length is only correct as long as you don't have regex quantifier expressions in the "words" - if you do, all bets are off. At any rate, if you're going to this effort, you should probably be using Regex::PreSuf.

Makeshifts last the longest.