I have following code for printing a simple hash.

#!/usr/bin/perl -w
 

%hash = ("abc" => 123, "dfg" => 456, "xsd" => 34);

foreach $k (keys %hash){
         print "key $k:: value $hash{$k}\n";
 }


It does not print keys and displays following warnings:

--------------
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 34
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 123
Use of uninitialized value $k:: in concatenation (.) or string at hash_test2.pl
line 7.
key  value 456


Never happened like this with hash . I am not sure where I am going wrong .





-Sunita































































                                          

Reply via email to