my $referencepixels=countpixels($referencefile); @data=ls($datadir) foreach my $file (@data){ my $cover=countpixels($file)/$referencepixels; $datahash{$file}=$cover; } output_to_datafile(%datahash);