Just use
%errors instead of
%$errors in this script. The syntax
%$errors means "the hash $errors points to". Since you don't have a variable $errors initialized with anything resembling a pointer it is no surprise perl doesn't know what you want
Note that $errors and %errors are totally different variables and have nothing but the name in common