in reply to ID exists in Hash -I need to copy the value even if it exists more than one
This shows, however, that using an array as the first level of the data structure is probably not the best idea: these 60 empty slots are a waste of memory. A HoA might be better:DB<4> @values = qw / 60 811/; DB<5> push @{$AoA[$values[0]]}, $values[1]; DB<6> @values = qw / 60 812/; DB<7> push @{$AoA[$values[0]]}, $values[1]; DB<8> x \@AoA 0 ARRAY(0x80430518) 0 empty slot 1 empty slot 2 empty slot 3 empty slot (...) 58 empty slot 59 empty slot 60 ARRAY(0x803f50f0) 0 811 1 812
DB<1> ($key,$val) = qw / 60 811/; DB<2> push @{$HoA{$key}}, $val; DB<3> ($key,$val) = qw / 60 812/; DB<4> push @{$HoA{$key}}, $val; DB<5> x \%HoA 0 HASH(0x80359cb0) 60 => ARRAY(0x8035ffa8) 0 811 1 812 DB<6> print "@{$HoA{60}}" 811 812
|
|---|