in reply to filtering readdir()'s results

you could change the line starting with  my @files to something like:
my @files = grep {/^xxxx/} readdir(DIR);

-enlil