in reply to Re: System(), writing to a new file
in thread System(), writing to a new file

Load all of the output of sort(1) to perl's memory, just to write it out to the file right after? Hardly efficient.

As mentioned below, system(@list) doesn't invoke the shell. This is usually a good thing, but in this case the shell redirection the OP is expecting won't work. system($string) invokes the shell. Hence, system("sort $infile > $outfile") will work.

However, there's a better approach: Use the -o flag to sort(1), like this: @args = 'sort', '-o', $outfile, $infile; system(@args);

Replies are listed 'Best First'.
Re^3: System(), writing to a new file
by cyates (Novice) on Jul 19, 2013 at 00:52 UTC
    Perfect. Thank you
      (Please ignore. I replied to the wrong node.)