my ($match)=$file=~/(\d{4})\d{4}\.txt/; #### my @a = map {/(\d{4})\d{4}\.txt/} @filenamearray;