perl指定位置输出



QUOTE:
原帖由 Vic_Yu 于 2008-1-2 11:11 发表


嘿嘿,按照你的意思,但是似乎我这里出错,我是在WINDOWS环境下运行perl的,错误信息:"Bad name after F' at C:\Documents and Settings....."

WINDOWS上'要换成"

perl -F"=" -lane "print $F[1] if /^aaa/" urfile
用shell

[Copy to clipboard] [ - ]
CODE:
cut -d "=" -f2 yourfile



QUOTE:
原帖由 ly5066113 于 2008-1-2 11:14 发表


WINDOWS上'要换成"

perl -F"=" -lane "print $F[1] if /^aaa/" urfile

似乎"F"这个东西有问题.错误信息:

String found where operator expected at C:\Documents and Settings\lyu\Desktop\Bb
\old.pl line 22, near "F"=""
String found where operator expected at C:\Documents and Settings\lyu\Desktop\Bb
\old.pl line 22, near "lane "print $F[1] if /^aaa/""
        (Do you need to predeclare lane?)
String found where operator expected at C:\Documents and Settings\lyu\Desktop\Bb
\old.pl line 22, near ""print $F[1] if /^aaa/" "C:\\Documents and Settings\\lyu\
\Desktop\\Bb\\1111.txt""
        (Missing operator before  "C:\\Documents and Settings\\lyu\\Desktop\\Bb\
\1111.txt"?)
syntax error at C:\Documents and Settings\lyu\Desktop\Bb\old.pl line 22, near "F
"=""
Execution of C:\Documents and Settings\lyu\Desktop\Bb\old.pl aborted due to comp
ilation errors.
perl -F"\=" -lane "print $F[1] if /^aaa/" urfile
写在脚本里了?

我这个是直接在 “命令行” 执行的啊!


QUOTE:
原帖由 alexru 于 2008-1-2 11:33 发表
perl -F"\=" -lane "print $F[1] if /^aaa/" urfile

perl -F"\=" -lane "print $F[1] if /^aaa/" 'C:\\Bb\\1111.txt'

我程序如上.还是有问题.
'C:\\Bb\\1111.txt'???

直接写成 "c:/xxxx/xxxx/xxxx"
或者  "c:\\xxxx\\xxxx\\xxxx"

":" 有没有\ 我忘了  - - 汗  学到没忘的多


QUOTE:
原帖由 ly5066113 于 2008-1-2 11:35 发表
写在脚本里了?

我这个是直接在 “命令行” 执行的啊!

命令行OK,要是放到脚本里面,应该如何改变一下呢?
谢谢大家,问题已经解决,继续下面的问题