>perl -wMstrict -le "my @elements = qw(stop sign light painter porch store front); my ($elem) = map qr{ $_ }xms, join q{ | }, @elements ; my $plural = qr{ e? s }xms; my $compound = qr{ \b $elem{2,} (?= $plural? \b) }xms; ;; my $str = qq{a signpainter wanted the stopsigns in front \n} . qq{of all his storefronts` frontporches replaced \n} . qq{by stoplights to reduce accidents in front \n} . qq{of his stores} ; print qq{[$str]}; ;; my @compounds = $str =~ m{ $compound }xmsg; printf qq{'$_' } for @compounds; " [a signpainter wanted the stopsigns in front of all his storefronts` frontporches replaced by stoplights to reduce accidents in front of his stores] 'signpainter' 'stopsign' 'storefront' 'frontporch' 'stoplight'