in reply to Help with code

You are declaring @dirlist inside a loop, so it goes out of scope before it can be used in the next loop. Put a my @dirlist before the loop (and just push onto a not-my'ed @dirlist in the loop) and you should be fine.

My question is, why are you creating a list from the readdir() and then copying the list to a second list? Why not just use @iresdir in your main for loop?