# - - - process_bio_data_in_directory.pl # Responsibility : process global results for all experiments. # Where to find the experiment directories and data files my $DATA_DIR = ‘C:/bio_data/’; my $experiment_dir_regex = qr/Exp/; my $data_file_regex = qr/data_/; ### Comment : i lined these three = signs, but the different font of the didn't leave them lined. That is very annoying, # 1. Find all the experiment directories, and their related data files my $list_experiments = find_experiments_and_their_data_files_in({ dir =>$DATA_DIR, with_experiment_regex => $experim_dir_regex, with_data_file_regex => $data_file_regex, }); ### Comment for the reader : ### an Experiment object will have a path, and a list of data_files. ### I feel that this class makes my code more readable, and i can use $data_file_regex here, ### and not have to think about it again. # 2. Process the data for each experiment my %global_results; EXPERIMENT: foreach my $experiment ( @{$list_experiments} ) { my $hash_aggr_infos = calculate_aggr_info_for_experiment($experiment); process_global_results_with( $hash_aggr_infos, \%global_results ); } #### # - - - calculate_aggr_infos.pm package Calculate::AggrInfos; # Responsibility : calculate the aggregate information for one experiment. sub calculate_aggr_infos_for_experiment { my $experiment = shift; # 1. Initialize Readers for each data file my $hash_data_reader_of_file = initialize_data_file_readers_for_experiment($experiment); # 2. Calculate aggregate information my $hash_aggr_infos = calculate_aggr_infos_with_readers( $hash_data_reader_of_file ); return $hash_aggr_infos; } # - - - end sub calculate_aggr_infos_for_experiment() #### # in the same file and package as before sub calculate_aggr_infos_with_readers { my $hash_data_reader_of_file = shift; my @data_files = keys %{$hash_data_reader_of_file}; DATA: while ( $hash_data_now = get_next_data_for_all_readers($hash_data_reader_of_file) ) { # check that the time value is the same for each set of data check_if_time_is_the_same_for_all_data($hash_data_reader_of_file); # calculate aggregated information my $hash_aggr_infos = calculate_aggr_infos_from_data($hash_data_now); # it’s a bit more complex, as i need a bit of “past data history” # to calculate the aggregated information } # end while (DATA) } # - - - end sub calculate_aggr_infos_with_readers()