my @words;
my $filename="terms.txt";
if (open my $FH, "<:encoding(UTF-8)", $filename) {
while (my $line = <$FH>) {
chomp $line;
push @words, $line;
}
close $FH;
}
my $wordsRX = join "|", map quotemeta, @commonwords;
####
#I read with the script above my @terms and then add new words to it, eliminate duplicates, if any, and write it back.
my @wordsfiltered = uniq_array(@terms);
my $fh = openFileAndWrite($filename);
foreach (@wordsfiltered){
print $fh $_ . "\n";
}
close $fh;
####
store(\@wordsfiltered, "terms.array");
my @words= @{ retrieve("terms.array") };