use warnings; use strict; use Lingua::Sentence; use Data::Dump; my $text = "I took the medicine that Dr. Wall recommended to me. It tasted like onions."; my $splitter = Lingua::Sentence->new("en"); my @sentences = $splitter->split_array($text); dd @sentences; for my $sentence (@sentences) { if ( $sentence =~ /\s(\w+)[^\w\s]?$/ ) { dd $1; } else { warn "Failed to get last word from: $sentence" } } __END__ ( "I took the medicine that Dr. Wall recommended to me.", "It tasted like onions.", ) "me" "onions"