... we declare all values in hash ...
Declare them as what? As Anonymous Monk pointed out above, the data you show is not a hash, it’s a list (of strings). Since you said this data is in a hash, I made a guess as to how the hash was contstructed. A hash is a collection of key/value pairs. Every key must have a value (and every value must belong to a key). I assumed that the data was stored as hash keys, so I supplied an undef value for each — but that could have been any value, as it isn’t used.
If your hash is really key/value pairs of the form: Chicago => 'USA' (another guess), adapting the answer I gave above should be quite straightforward.
Hope that helps,
| [reply] [d/l] [select] |
Thank you well explanation.
my%hash = (Script => "Perl",
script_1=>"Ruby",
script_2=> "PHP");
for my$k (keys %{my$href}) {
print "$k => ${$href}{$k}\n";
}
it showing Global symbol $href requires explicit package name.why this error.? | [reply] [d/l] [select] |
it showing Global symbol $href requires explicit package name.why this error.?
because you're copy/pasting the wrong things , without understanding what they mean
Why do you introduce $href? Think about that
Then see the documentation for keys function, how is it different from your example?
Try keys %hash
| [reply] |