use strict; use warnings; my @dir; my @filelist; open OUT, ">result.fst"; opendir (DIR, "./") or die "can't open the directory!"; @dir = readdir DIR; foreach my $file (@dir) { if ( $file =~ /[a-z]*\.seq/) { push @filelist,$file; } } closedir(DIR); foreach my $file (@filelist){ open IN, "<".$file or die "cannot open $file"; print OUT ">".$file."\n"; print OUT <IN>; close(IN); } close (OUT);