Your system call starts a separate process, while Perl's own rmdir will call its own C function in the context of the Perl process. Both methods end up making the same system calls, but opening a new process is less efficient. *
Itโs best to use Perl's own functions (like rmdir ): they are portable, and you donโt have to worry about how to interpret shell exit codes, avoid metacharacters in file names to prevent security risks, etc.
* system will create an additional sh process if your command contains channels, I / O redirection, && , etc. This is not applicable in your case, but can make the system parameter even slower.
source share