in reply to Creating Hash of Arrays
When you assign an array to a scalar like you have below, it assigns the number of elements as you've found.
$bin_file_data{$sampname} = @bindata;
What you want to do is stuff a reference to the array as the value to the key:
$bin_file_data{$sampname} = \@bindata; # a different way that copies @bindata as opposed # to taking a direct reference to it @{ $bin_file_data{$sampname} } = @bindata;
Then:
# use the whole array for (@{ $bin_file_data{$sampname} }){ ... } # get a single element my $thing = $bin_file_data{$sampname}->[0];
-stevieb
|
|---|