我试图运行多个Perl的在PowerShell中的命令行命令在Windows 8在Windows 8 PowerShell ISE中运行草莓的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→更改分隔符。 – amon 2013-03-25 21:10:30