the below script stores the key value pairs. Based on the input key given it should retrieve the corresponding value. In below code I am able to see the key value pairs from the first print but when I give one of the keys as an input, it throws an error saying "uninitialized hash". How to solve this ?
...
for my $key ( sort keys %hash ) {
print "$key = $hash{$key}\n";
}
my $key = <STDIN>;
print "list is = $hash{$key}\n";
$key
contains the line entered including the trailing line feed . Add
chomp($key);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.