in reply to Can't seem to see the problem here...

Check the return status of your opendir with opendir(DIR."$dir") or die "Could not open $dir: $!" My bet is on your needing a chomp to get rid of a newline