Perl Programming Question:
Download Questions PDF

How to read file into hash array ?

Answer:

open(IN, "<name_file")
or die "Couldn't open file for processing: $!";
while (<IN>) {
chomp;
$hash_table{$_} = 0;
}
close IN;

print "$_ = $hash_table{$_}n" foreach keys %hash_table;

Download Perl Programming Interview Questions And Answers PDF

Previous QuestionNext Question
How do I sort a hash by the hash value?How do you find the length of an array?