open my $file, '<', 'words.txt' or die "Can't open words: $!"; my @listOfWords = (<$file>); chomp @listOfWords; close $file;