messages messages. messages.1 messages1.2.3 messages.1.gz messages.2 messages.3 messages.pl messages.txt #### opendir D, '.'; while(readdir D) { /^messages(?:\.\d?)?$/ and print $_,"\n"; } #### messages. messages.2 messages messages.1 messages.3 #### opendir D, '.'; while(readdir D) { m/ # begin of match ^ # match at the beginning of element, i.e. $_ messages # match 'messages' literally ( # begin of match group ?: # subject to * ? + not creating a capture \. # match a period \d? # optionally (?) match a digit ) # end of match group ? # which may or not occur $ # before the end of the string /x # tell m// that we use extended regex w/comments and # if found print "$_\n" # print it out. }