Check your for-loop at the end of your code. You declared $o (letter o) as loop variable and then you use $0 (number 0 (zero)) inside the system call to create the filename...
Comment on Re: how to save result in multiple files using for loop in perl