作者dipin (吃喝玩乐满天下)
看板perl
标题Re: [问题] activePerl -e 的使用
时间Fri Jan 26 07:57:26 2007
※ 引述《dipin (吃喝玩乐满天下)》之铭言:
: 我装了ActivePerl之後 开始写了一些程式
: 一切都还满顺的
: 可是写了一阵子之後 想试试-e这个指令
: 却没办法用
: 像是我在命令提示的视窗里,perl的目录打入
: C:\Perl\perl -e 'print "Hello Perl !!\n";'
: 会显示
: Can't find string terminator "'" anywhere before EOF at -e line 1.
: 请问是出了什麽问题呢?
找到解答了!! \^o^/
在activePerl所附的说明里有说到:
Why doesn't 'perl -e' work?
It does - it's just that some command shells (for example COMMAND.COM,
CMD.EXE and 4DOS) don't accept single quotes wrapped around command arguments.
The safest way to do perl one-liners is to wrap the parameters within ""
(double-quotes) ,then use q() and qq() inside the parameters. q() and qq()
with put whatever is inside them between single-quotes or double-quotes,
respectively.
For example:
perl -e "use LWP::Simple; while(@c = head <>) { $c = join qq(\n\t),
@c; print qq(Header info:\n\t$c\n); }"
(this was all one line)
Run this from the command line and type in the URL to your favorite
website, like
http://www.perl.com/.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 76.171.92.173