I doubt either perl or your OS has a problem opening & closing 300/400 files. So I'm just offering general advice.
- Your program uses $pathC and $cpath. Is this a typo? Adding use strict; and use warnings; would catch that and many other errors (if you're not using thm already, of course).
- Perl will tell you why the open failed in the special variable $!.
- Is there a good reason why you're opening & closing STDIN? I doubt it's necessary.