Whenever I iterate over a hash with my keys and then print each value, I get "using an uninitialized value in a concatenation (.) Or string ...". Although the hash is clearly initialized in front. The conclusion I need is printed, but I still would like to know why this leads to a warning, especially since accessing the value directly (outside the loop) works without warning.
#!/usr/bin/perl use warnings; use strict; my %fruit = (); %fruit = ('Apple' => 'Green', 'Strawberry' => 'Red', 'Mango' => 'Yellow');
Consider the code above. I think perl sees the difference between the first print and the second print. But why? Why is there a difference between retrieving the hash value outside the loop and retrieving the value of a inside the loop?
Thanks!
Gx1sptDTDa
source share