On 22 Jun 2014, at 21:01, Sunita Pradhan <sunita.pradhan.2...@hotmail.com> 
wrote:

> 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";
>  }
> --------------
> Use of uninitialized value $k:: in concatenation (.) or string at 
> hash_test2.pl

Try this:

#!/usr/bin/perl -w
use strict;
my %hash = (
        "abc" => 123,
        "dfg" => 456,
        "xsd" => 34
);
foreach my $k (keys %hash){
        print "key $k\:: value $hash{$k}\n";
}

#JD

Reply via email to