Perl – What’s the differences between system and backticks and pipes in Perl

backticksperlpipesystem

Perl supports three ways (that I know of) of running external programs:

system:

   system PROGRAM LIST

as in:

system "abc";

backticks as in:

`abc`;

running it through a pipe as in:

open ABC, "abc|";

What are the differences between them? Here's what I know:

  1. You can use backticks and pipes to get the output of the command easily.
  2. that's it (more in future edits?)

Best Answer

  • system(): runs command and returns command's exit status
  • backticks: runs command and returns the command's output
  • pipes : runs command and allows you to use them as an handle

Also backticks redirects the executed program's STDOUT to a variable, and system sends it to your main program's STDOUT.