$data[1]->{'477'}->[5] = [ 'value', 'value', 0 , undef, 5, 'value' ]; #### use MLDBM qw(DB_File Storable); # ... stuff .... foreach $gid (@group_ids) { my %temp_hash; unlink "$DBFilePath/$$.$gid" if -e "$DBFilePath/$$.$gid"; tie %temp_hash, 'MLDBM', "$DBFilePath/$$.$gid", O_RDWR|O_CREAT, 0640 or die "Can't tie temp_array to $DBFilePath/$$.$gid: $!"; $data[$gid] = \%temp_hash; foreach $sample_id (@{$groups[$gid]}) { foreach $element_num ( 0 .. $element_count ) { $element = []; # ... do a bunch of stuff here ... $data[$gid]->{$sample_id}->[$element_num] = $element; } } } #### $tmp = $data[$gid]->{$sample_id}; $tmp->[$element_num] = $element; #### $tmp = $data[$gid]; $tmp=>{$sample_id} = [ $element1, $element2, ... ];