in reply to Re^6: System call doesn't recognise '>'
in thread System call doesn't recognise '>'

Ahh, methinx the mists begin to clear a little more (& not before time, I hear you say;-) ... '>' is an argument to the shell, not $command, thus if you need the output redirected in the manner you require, you'll have to use system "@array > $outfile" form - assuming @array contains $command.

Alternatively you could use perl to perform the redirection by using open e.g.

open CMD, "@array > $outfile" or die "open() failed - $!";
In both cases, auto-stringifying the array.

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^8: System call doesn't recognise '>'
by Lauras (Initiate) on Dec 10, 2008 at 21:42 UTC
    my @array = ($command, $arg1, $arg2, $arg3); system "@array > $outfile";

    Results in:

    Can't spawn "cmd.exe": No such file or directory at D:\advanced_progra +mming\test_syscall.pl line 11. and my @array = ($command, $arg1, $arg2, $arg3); open CMD, "@array > $outfile" or die "open() failed - $!";

    gave:

    Name "main::CMD" used only once: possible typo at D:\advanced_programm +ing\test_syscall.pl line 17. open() failed - Invalid argument at D:\advanced_programming\test_sysca +ll.pl line 17.