in reply to trouble with system commands

So you're trying to process files in a directory? perldoc -f glob Combine that with a while loop and you may not need a system call or $chdir at all.