in reply to problem with system function

perldoc -f system

You probably don't want to pass the arguments as two separate strings. The system() function will treat each argument as a separate argument to the executed program. If you are breaking it up to make your code more readable, try:

system("$CMD $arg1 $arg2");