use strict; use warnings; use Lingua::StopWords qw(getStopWords); { open my $infile, ' }; $fulltext =~ s/ *?\b$_\b *?//gi for keys %{ getStopWords('en') }; open my $outfile, '>nostopwords.txt' or die $!; print $outfile $fulltext; }