my %hash; open my $INPUT, "<", $file_in or die "Cannot open $file_in $!"; # the die "..." part is not needed if you use autodie. while (my $line = <$INPUT>) { chomp $line; $hash{$line} = 1; # or undef or anything you like for the value } close $INPUT; # You can use %hash for lookup now