in reply to error on file open

Others have addresed the main issues in your program., but I thought I would point out that the first file returned is likely "." followed by ".."

Also, I don't understand why you base your loop on a comparison of $comp_name and $threenodes. These do not appear to change within the while loop. If it didn't die, it looks like an infinite loop.