foreach $filename (@input_names) #Go through input files { ($names_ref,$data_ref) = &read_file($filename); @tmp_names = @$names_ref; @tmp_data = @$data_ref; foreach $name (@tmp_names) #Go through lines of current input file { $index = &find_element($name, @names); #Check if variable is already present in name array (time consuming!) if ($index==-1) #Name not present, put both name and data in array { push(@names,$name); push(@data,$tmp_data[$tmp_index]); } else #Name present, only replace data for the name { $data[$index] = $tmp_data[$tmp_index]; } $tmp_index++; } }