in reply to Run multiple shell commands on the same perl script
Hello Daral, and welcome to the Monastery!
As 2teez explained, you can use system to run an external command from within a Perl script. But note that system returns the command’s exit status, not its output. If you want to capture the command’s output, use backticks (or the equivalent qx operator):
#! perl use strict; use warnings; my $ls = `ls`; print "Output from ls:\n\n", $ls, "\n"; my $con = `ipconfig`; print "Output from ipconfig:\n\n", $con, "\n";
Update: To capture both the output and the exit status, use the module Capture::Tiny.
Hope that helps,
Athanasius <°(((>< contra mundum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Backticks and exit status
by space_monk (Chaplain) on Oct 31, 2012 at 14:25 UTC |