in reply to checking to see if a directory is empty

You could go globbing:

my $num; chdir $dir_to_check; $num++ while <*>; print "There are still files in $dir_to_check\n" if $num;

Update Used a better glob.