Perl's system() function has two modes: if you give one argument, it will have this string parsed by a "shell"; if you give an array, it will use the first one as program name, and directly pass the following things to the program without the process by a "shell"
We know that the second mode is more safe, as it avoids the arguments with spaces being splitted into multiple arguments. So we should prefer the second mode. However, I don't know how to use ">file" in the second mode. If you provide it, it will be transferred into the program, not performing an output redirection. For example:
# This works
system("cat foo >bar");
# ">bar" being passed to cat as an argument
# and there's no file named ">bar"
system('cat', 'foo', '>bar');
Thanks!