Search code examples
perlhashsyntax

Error: Type of arg 1 to each must be hash (not hash element)


I'm getting this error when attempting to run this script - on this line

Type of arg 1 to each must be hash (not hash element)

    while (my ($action, $value) = each($cameras{$camera}{$mode})) {

How do I fix this error?


Solution

  • Dereference the hash:

     while (my ($action, $value) = each(%{ $cameras{$camera}{$mode} })) {