sub consolidate_logs ($$$) { my ($destination_file, $dir, $filename_str) = @_; my @files = get_matching_filenames($dir, $filename_str); open(OUT,"> $destination_file") or die "Could not open file \"$destination_file\" for writing"; foreach my $source_file (@files) { print "Processing of log \"$source_file\" started at " . localtime() . "\n"; system("cat $dir/$source_file >> $destination_file"); print "Processing of log \"$source_file\" ended at " . localtime() . ".\n"; } close(OUT); }