This is just a guess so don't yell if I'm wrong.
I believe the problem is that when installing perl you register .pl filehandles and what not, but you also put the perl path in your envirmental path variable. Now I would assume that you have that path because I'll assume you ommitted perl when you ran it without the " > test.out" and you get output when you run it with the perl ommitted.
At first i thought it was a problem with your shebang line; however, that isn't what is causing the problem because I still got that error when running it on a windows machine. Next I thought it might be from the -w. Crash and burn also. Then I struck gold. The problem is in your code itself. For some reason or another the command.exe shell is catching on you system call. It is not a problem with the shell. It is a problem with the code itself.
I believe it is because when you call a system command in perl, you send the command directly to the system, bypassing perl (except perl returns 1 or 0 for success). This somewhat confuses windows (for lack of a better term). This may not be the explanation you were looking for, but it's all i got.