my %all_my_hashes; $all_my_hashes{$variable} = { valorC => "value03", valorD => "value04", }; print $all_my_hashes{$variable}, "\n"; # later you read ; records while (<>) { # consider Text::CSV_XS with sep_char => ";" my @alelos = split ";" => $_, -1; while (@loci_codes) { $variable = shift @loci_codes; $all_my_hashes{$variable}; my $allele1 = shift @alelos; my $allele2 = shift @alelos; $all_my_hashes{$variable}{$allele1) += 1; $all_my_hashes{$variable}{$allele2} += 1; } $all_my_hashes{Bet01} = { 230 => 2, 238 => 5, 224 => 1, }; $all_my_hashes{Bet05} = { 101 => 2, 103 => 2, 0 => 4, };