Looks ok-ish to me. I'd do it differently, and in any case, you should start all Perl progs with
for best practice.
The core of your loop I'd do more like this
opendir(DIR, $dirname) or die "Can't opendir $dirname: $!\n";
while (defined($file = readdir(DIR)))
next if $file =~ /^\.\.?$/; # skip . and ..
# do something with "$dirname/$file"
closedir(DIR) or die "Can't closedir $dirname: $!\n";
As the Perl Cookbook points out
As explained in the Introduction, the filenames returned by readdir do not include the directory name. When you work with the filenames returned by readdir, you must either move to the right directory first or prepend the directory to the filename.