#!/usr/bin/perl -w use strict; use File::Find; ### User-modifiable variables ### my $reg = 'AZT,IOP,AERTC'; my $week = 'W36'; ### User-modifiable variables ### # Get the dirlist for File::Find my @dirs = glob "semaine_$week/Regulation_{$reg}"; # The 'find' subroutine comes from 'File::Find' find(\&process, @dirs); my %seen; sub process { # Skip if we've already processed the file in this directory next if $seen{$File::Find::dir}; # Skip unless the file matches the spec next unless /^slot_list\w*.\d\d\.01\.\w+\.out$/; # We've found the file that we want; now, we'll process it open Out, ">results.csv" or die "results.csv: $!\n"; open Fh, $_ or die "$_: $!\n"; while (my $line = ){ chomp $line; my ($key, $val) = split /;/, $line; print Out "$key;$val\n"; } close Fh; close Out; # Mark directory as 'processed' $seen{$File::Find::dir}++; }