in reply to How to read from a file instead from a hard coding list.

You could slurp the whole file into a variable like this

use warnings; use strict; my $filename//=$ARGV[0]; # i.e script.pl path_to_file my $data; open my $fh,'<',$filename or die"can't open file:$!"; $data=do{local $/; <$fh>}; ## slurp the whole file once close $fh; my @guesses=(); my $wrong=0; my @words=split/\s+?/,$data; my $choice=$words[rand @words]; ....... # rest of the program

hope this helps