¿Cómo puedo usar hashes como argumentos para las subrutinas en Perl?
Me pidieron que modificara algún código existente para agregar alguna funcionalidad adicional. He buscado en Google y parece que no puedo encontrar la respuesta. Tengo algo en este sentido ...
%first_hash = gen_first_hash();
%second_hash = gen_second_hash();
do_stuff_with_hashes(%first_hash, %second_hash);
sub do_stuff_with_hashes
{
my %first_hash = shift;
my %second_hash = shift;
# do stuff with the hashes
}
Estoy recibiendo los siguientes errores:
Odd number of elements in hash assignment at ./gen.pl line 85.
Odd number of elements in hash assignment at ./gen.pl line 86.
Use of uninitialized value in concatenation (.) or string at ./gen.pl line 124.
Use of uninitialized value in concatenation (.) or string at ./gen.pl line 143.
Las líneas 85 y 86 son las primeras dos líneas en la sub rutina y 124 y 143 son donde estoy accediendo a los hashes. Cuando busco esos errores, parece sugerir que mis hashes no están inicializados. Sin embargo, puedo verificar que los hashes tienen valores. ¿Por qué estoy recibiendo estos errores?