It's common to run a command in perl, actually, in perl, there are three common ways to do so.

system(), backticks, exec. for example:

system("ls");
`ls`
exec 'ls'

Which one is better ? what's different amoung them?

system

system executes a command and your Perl script is continued after the command has finished. And it returns only the command return code, not the STDOUT and STDERR. So, remember to use redirection to capture the command output. For example:

$ret=system("ls >ls.output"); 

Where $ret captures the return code from system call, similar to $? in shell.

exec

Executes a command without involving a shell process. It's a function in perl, thus It's like a return statement in a function.
 
If the command is not found exec returns false. Because if the command is found it never returns at all.

It's perfect for some tasks/jobs that don't want to wait for return. Here is an example with fork.

sub my_exec {
    die "could not fork\n" unless defined(my $pid = fork);
    return waitpid $pid, 0 if $pid; #parent waits for child
    exec @_; #replace child with new process
}

backticks

like system executes a command and your perl script is continued after the command has finished.
 
In contrary to system the return value is STDOUT of the command. qx// is equivalent to backticks.

 my $output = qx/command arg1 arg2 arg3/;
 my $output = `command arg1 arg2 arg3`;

 

Other ways ?

 
There are also several modules which can ease this tasks. There is IPC::Open2 and IPC::Open3 and IPC::Run, as well as Win32::Process::Create if you are on windows.

open: run a process and create a pipe to its STDIN or STDERR 

Use open when you want to write data to a process's STDIN or read data from a process's STDOUT (but not both at the same time).

#read from a gzip file as if it were a normal file
open my $read_fh, "-|", "gzip", "-d", $filename
    or die "could not open $filename: $!";
 
#write to a gzip compressed file as if were a normal file
open my $write_fh, "|-", "gzip", $filename
    or die "could not open $filename: $!";

IPC::Open2: run a process and create a pipe to both STDIN and STDOUT 

Use IPC::Open2 when you need to read from and write to a process's STDIN and STDOUT. 

use IPC::Open2;
 
open2 my $out, my $in, "/usr/bin/bc"
    or die "could not run bc";
 
print $in "5+6\n";
 
my $answer = <$out>;

IPC::Open3: run a process and create a pipe to STDIN, STDOUT, and STDERR 

use IPC::Open3 when you need to capture all three standard file handles of the process. It works mostly the same way IPC::Open2 does, but with a slightly different order to the arguments and a third file handle.