I'm giving some maintenance on a perl system (language that I'm noob) and I needed to create a new report module where I need to solve the following situation:
I have 2 arrays with the following formats
@head = ("nomeinstituicao", "cnpjinstituicao","nomecliente", "cnpjcliente", "notacliente" );
@data = ("inst1", "12345678000112","joao",
"87654321000198","5","inst2","54387612000123","maria","45612387000123","6",...);
I need to produce a hash in the following format:
%hash = (
"nomeinstituicao" => "inst1",
"cnpjinstituicao" => "12345678000112",
"nomecliente" => "joao",
"cnpjcliente" => "87654321000198",
"notacliente" => "5",
"nomeinstituicao" => "inst2",
"cnpjinstituicao" => "54387612000123",
"nomecliente" => "maria",
"cnpjcliente" => "45612387000123",
"notacliente" => "6",
...
);
Can anyone help me with a way to do this transformation dynamically taking into consideration that the data contained in $data
I am looking for in the DB.
I'm trying all day and I have not been able to do it until now, I have tried map
and while
but I do not think I'm doing it right.