in reply to Am I on the right track?

my @files = grep {!/^\./ && -f "$dir"."data2/$_" } readdir($dh);

A small point: If you're trying to filter out the . and .. directories from what you are reading from the directory handle, be aware that  !/^\./ will also filter out files named something like '.foo'. The idiomatic pattern to use here would be  !/^\.\.?$/ or maybe  m{ \A [.]{1,2} \z }xms instead.


Give a man a fish:  <%-(-(-(-<