in reply to system($cmd) spawns infinitely

This may be a bit like stating the obvious, but could you reassure me that the code that calls system() isn't a part of your sync_mumoodle.pl script!

One way to get into an infinite loop would be to have a script recursively call itself. Not that I'm speaking from bitter experience, of course...

use JAPH;
print JAPH::asString();