I am writing a perl script which is always running and keep check for new arrived files. One new files arrives, it will first uninstall the previous version and then start install the new version. while(1) { $newVersion = check if new version arrives();

if($newVersion) { exec($unInstallCommand); exec($installCommand); }

}

I am using exec to execute the uninstall and install, but after the unInstall finishes, the perl script exit from the while loop, which is not what I want. If I use System instead of exec command, how can I ensure the install starts after the completion of uninstall?