为什么此Perl单行代码在Windows上不起作用? [英] Why doesn't this Perl one-liner work on Windows?

查看:79
本文介绍了为什么此Perl单行代码在Windows上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在命令窗口中运行一个简单的Perl脚本,并且出现错误:

Trying to run a simple Perl script in a command window and am getting error:

在-e第1行EOF之前的任何位置的字符串终止符'"

string terminator "'" anywhere before EOF at -e line 1

代码

perl -e 'print "Hello World";'

我在做什么错了?

推荐答案

哪个平台?如果是Windows和CMD.EXE,那么各种各样的事情都可能出错.在类似Unix的平台上,应该可以正常工作.末尾没有换行符,因此您的提示似乎以"Hello World"开头,仅此而已.

Which platform? If it was Windows and CMD.EXE, then all sorts of things could be going wrong. On a Unix-like platform, that should work fine. No newline at the end, so it's likely your prompt would appear to start with 'Hello World', but that's all.

在说它是Windows的情况下,问题在于Windows CMD.EXE不能与Unix一样解析命令行,并且不能简单地在参数周围使用单引号.您必须使用双引号.试试:

With the comment that it is Windows, then the trouble is that Windows CMD.EXE does not parse the command line the same as Unix, and you can't simply use single quotes around arguments; you have to use double quotes. Try:

perl -e "print qq{Hello World\n}"

有一个很小的机会为您服务.

There's a modest chance it will work for you.

这篇关于为什么此Perl单行代码在Windows上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆