#! /usr/bin/perl use strict; use warnings; # https://www.perl-community.de/bat/poard/thread/18288 use File::Find; # for searching for files/directories use File::Spec::Functions qw( catfile ); # for creating portable file-paths use Cwd; # for determing current work directory my @directories = ( # where do you want to search? '/path/to/data/dir', # herein are the .ffn files; ADJUST THIS PATH ); my %match; # storage for matching file paths # this routine is to be changed to do the job of data extraction and combination # ADJUST THIS CODE if test run was successful sub combine_to { my $newfile = shift; my $directory = shift; my $filesRef = shift; # DEBUG output warn <= @files; } # search for files and fill @matches find( \&find_ffn_files, @directories ); # check %match for my $dir ( keys %match ) { # combine found files into 'combined.ffn' in corresponding directory combine_to( 'combined.ffn', $dir => $match{$dir} ); }