【发布时间】:2013-03-15 12:20:31
【问题描述】:
我正在尝试从 Windows 8 的 PowerShell 中的命令行运行多个 Perl 命令。
这行得通
perl -e "print 'Joe'";
这打印:
Joe
这不起作用
perl -e "my $string = 'Joe'; print $string;"
这给了我一个错误
perl : syntax error at -e line 1, near "my ="
At line:1 char:1
+ perl -e "my $string = 'Joe'; print $string;"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (syntax error at -e line 1, near "my =":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Execution of -e aborted due to compilation errors.
有人能指出我遗漏的明显错误吗?谢谢。我通常在 UNIX 上这样做,但使用反引号。作为包装而不是双引号。
【问题讨论】:
-
我不知道 PowerShell,但看起来变量
$string被插入到-e代码之前它作为参数传递给 Perl → 更改分隔符。
标签: perl powershell windows-8