Re: [問題] activePerl -e 的使用
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章