RosettaCodeData/Task/Execute-a-system-command/Perl/execute-a-system-command.pl

10 lines
334 B
Perl
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
my @results = qx(ls); # run command and return STDOUT as a string
2013-04-10 16:57:12 -07:00
2019-09-12 10:33:56 -07:00
my @results = `ls`; # same, alternative syntax
2013-04-10 16:57:12 -07:00
2019-09-12 10:33:56 -07:00
system "ls"; # run command and return exit status; STDOUT of command goes program STDOUT
2013-04-10 16:57:12 -07:00
2019-09-12 10:33:56 -07:00
print `ls`; # same, but with back quotes
exec "ls"; # replace current process with another