in reply to Putting text file into a hash
I've started playing around with perl just a week ago
Some comments unrelated to your question:
Avoid using global variables. Use lexical variables for file handles.
open my $fh, "text_file_with_words.txt" or die; while (my $line = <$fh>) { ... }
$! contains an error message when open fails.
I prefer to use the three argument form of open. It has fewer possible surprises.
open(my $fh, '<', $qfn) or die("Can't open input file \"$qfn\": $!\n");
(my $var1, my $var2)
can be written as
my ($var1, $var2)
|
|---|