in reply to system($cmd) spawns infinitely

There is nothing special about calling a perl script via system, so I'd wager the problem lies elsewhere, in the code or the circumstances not mentioned.

Try to create a minimal but complete set of code samples and step-by-step instructions that would allow someone else to replicate the problem. In the process of doing so, you will maybe discover what the problem is. If not, post what you've come up with here.