Rather than writing your own directory scanner, you should consider using
File::Find. Your code is going to have potential problems if you hit a symlink.
There are a number of nodes regarding this problem, and it's one of
merlyn's pet peeves. Take a look through them (you can find them from his homenode, or use 'super search' in the search box at the top to find) to see what the issues regarding looping through a directory yourself are.
Here's a list for you (Gah! Doesn't ANYONE else besides
merlyn talk about the danger of this? <G>)
Re: Recursion problem,
RE: RE: RE: RE: Re: Its not supposed to!, and
WARNING t0mas wrote BAD CODE
--Chris
e-mail jcwren