【发布时间】:2015-03-09 21:05:30
【问题描述】:
我正在尝试在我的一个 perl 脚本中执行代码并出现错误,我如何执行以下 shell 命令并存储在变量中
#!/usr/bin/perl -w
my $p = $( PROCS=`echo /proc/[0-9]*|wc -w|tr -d ' '`; read L1 L2 L3 DUMMY < /proc/loadavg ; echo ${L1}:${L2}:${L3}:${PROCS} );
print $p;
错误:
./foo.pl
Bareword found where operator expected at /tmp/foo.pl line 3, near "$( PROCS"
(Missing operator before PROCS?)
syntax error at /tmp/foo.pl line 3, near "$( PROCS"
Unterminated <> operator at /tmp/foo.pl line 3.
怎么了?
【问题讨论】:
-
可能是
$之前的( -
Run Shell command in Perl 的可能副本。提示:有时查找如何做某事比调试您尝试做的错误更容易。在这种情况下,你发明了一些 perl 不支持的
$(syntax)。 -
@thatotherguy 我也试过
ehco但没用:( -
你想要什么输出?在 perl 中你几乎不需要
echo。 -
为什么
down给这个问题投票?