opendir D, '.'; while(readdir D) { /^messages(?:\.\d?)?$/ and print $_,"\n"; }