in reply to how to avoid opening and closing files
Can I just open once a file and remove all lines together having words stored in words.txt?
See map and grep
(and specially "grep (!/regex/) the_file", where regex should match words stored in words.txt
my @X; while(<INFILE>){ push @X,(split(/\s+/,$_))[0];} ### choosing particular column and pushing all its values in single ar +ray
I guess that a hash (%X) could be better here, but if you want an array, think in an unique sorted list or so. The idea is to avoid duplicates.
In Section
Seekers of Perl Wisdom