#!c:\perl\bin\perl use Storable; #use this for calling the hash storing functions. my %dict; # the hash while (my $line = ) { chomp $line; $dict{$line}++; # instead of ++ you could also assign some value. +.. } store(\%dict, "hash.txt"); #store the hash in the file. %dict = %{retrieve("hash.txt")}; #retrieve the hash from the file "hash.txt". thus, it only needs to be generated once. my @inputs = qw( foo fooed fooen prefoo postfoo ); for my $input (@inputs) { print "found '$input' in lexicon\n" if exists $dict{$input}; }