use Modern::Perl; use Lingua::StopWords qw( getStopWords ); my $str = "is that true"; my $str1 = "this is from presentation"; my $str2 = "to create"; say removeStopWords( eval $_ ) for qw{$str $str1 $str2}; sub removeStopWords { my $stopWords = getStopWords('en'); join ' ', grep { !$stopWords->{$_} } split ' ', $_[0]; } #### true presentation create