On 06/22/2014 04:01 PM, Sunita Pradhan 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";
  }


It does not print keys and displays following warnings:

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

your bug is putting ::after the $k. that makes it a package variable in the k:: namespace and there is nothing there. remove the :: or use some other marker or a space before the ::.

uri


--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to