- 论坛徽章:
- 145
|
回复 8# tc1989tc
$ perldoc perlop
NAME
perlop - Perl operators and precedence
DESCRIPTION
Operator Precedence and Associativity
Operator precedence and associativity work in Perl more or less like they
do in mathematics.
....
qx/STRING/
`STRING`
A string which is (possibly) interpolated and then executed as a
system command with "/bin/sh" or its equivalent. Shell wildcards,
pipes, and redirections will be honored. The collected standard output
of the command is returned; standard error is unaffected. In scalar
context, it comes back as a single (potentially multi-line) string, or
undef if the command failed. In list context, returns a list of lines
(however you've defined lines with $/ or $INPUT_RECORD_SEPARATOR), or
an empty list if the command failed.
Because backticks do not affect standard error, use shell file
descriptor syntax (assuming the shell supports this) if you care to
address this. To capture a command's STDERR and STDOUT together:
$output = `cmd 2>&1`;
To capture a command's STDOUT but discard its STDERR:
$output = `cmd 2>/dev/null`;
To capture a command's STDERR but discard its STDOUT (ordering is
important here):
$output = `cmd 2>&1 1>/dev/null`;
To exchange a command's STDOUT and STDERR in order to capture the
STDERR but leave its STDOUT to come out the old STDERR:
$output = `cmd 3>&1 1>&2 2>&3 3>&-`;
|
|