我正在尝试从 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 上执行此操作,但使用反引号。作为包装而不是双引号。