in reply to Deleting values from string using array
Perhaps it's just a coincidence, but all the words in your array are stop words. Since you've already been given excellent examples of how to work with your specific variables, here's an option that removes stop words from the strings you've provided--in case that's your primary goal:
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]; }
Results:
true presentation create
Just include line 2 above in your code, and send a string to removeStopWords and it'll return it sans any stop words.
Hope this helps!
|
|---|