Newcomer to Perl so I suspect there is a simple solution to this but I cannot see it despite extensive Googling.
my @special_things = get_special_things(\@allThings);
sub get_special_things {
my $things = shift;
my @specialThings;
foreach my $thing (@$things) {
if ($thing{special} == 1) {
push(@specialThings, $things);
}
}
return @specialThings;
}
The array of allThings being passed in is an array of hashes. I am getting an error on the foreach line telling me that 'Global symbol "%thing" requires explicit package name'.
I know this has something to do with referencing the hash value or key but I am at a loss at the minute. Any help is much appreciated.
$thing{special}means the element with keyspecialof hash%thing