Below is hash which contains reference to variables:
my %mandatoryFields = (
1 => \$msgtype,
2 => \$switchtype,
3 => \$card_nbr,
4 => \$natv_tran_type_code,
5 => \$amt_1
);
This works:
foreach my $field (keys %mandatoryFields) {
my $value = $mandatoryFields{$field};
unless ($$value) {
# do something
}
}
This dosen't: WHY ? The code never gets inside the unless block even though any variable inside the hash is undefined.
foreach my $field (keys %mandatoryFields) {
unless ($$mandatoryFields{$field}) {
# do something
}
}