由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to print \t in perl one-liner?
相关主题
what is used to represent a "tab" character in "sed"一个perl bug,求救,谢谢!
这个 perl 输出的数字为什么自动加了换行?谢谢!compare double to float
How to encode YYYY-MM-DD?这个perl的简单小程序为什么不work? (转载)
入门问题,perl里s@\_@@g 是什么意思?50伪币:请教perl代码差错的问题!多谢啦!
问一个perl/php问题还是PERL问题
perl questionperl problem
请 教 : 关 于 writing to a file 用 Perl for CGI一个 perl 的 print 的初级问题
再 次 请 教 : 关 于 writing to a file 用 Perl for CGI脚本问题求教
相关话题的讨论汇总
话题: perl话题: print话题: tab话题: liner话题: log
进入Programming版参与讨论
1 (共1页)
s***r
发帖数: 32
1
Hi,
I wanted to do sth like:
perl -F"\t" -lane "print $F[0], "TAB", log($F[1])" infile.txt
There is a problem with the TAB character: I can not find a way to represent
it in a way that perl recognize.
So I have to hack sth like:
perl -F"\t" -lane "print $F[0], _______, log($F[1]+1)" in.txt|perl -pi -e "s
/_______/\t/g"
Any better ways of doing it? Thanks!
X****r
发帖数: 3557
2
Don't you need to esacpe $ against shell?
Under bash:
perl -F"\t" -lane "print \$F[0], \"\t\", log(\$F[1])" infile.txt

represent
e "s

【在 s***r 的大作中提到】
: Hi,
: I wanted to do sth like:
: perl -F"\t" -lane "print $F[0], "TAB", log($F[1])" infile.txt
: There is a problem with the TAB character: I can not find a way to represent
: it in a way that perl recognize.
: So I have to hack sth like:
: perl -F"\t" -lane "print $F[0], _______, log($F[1]+1)" in.txt|perl -pi -e "s
: /_______/\t/g"
: Any better ways of doing it? Thanks!

s***r
发帖数: 32
3
Great! \"\t\" works! Thanks!
t****t
发帖数: 6806
4
it has nothing to do with tab, you are using wrong quotes (for shell)
perl -F"\t" -lane 'print $F[0], "\t", log($F[1])' infile.txt

represent
"s

【在 s***r 的大作中提到】
: Hi,
: I wanted to do sth like:
: perl -F"\t" -lane "print $F[0], "TAB", log($F[1])" infile.txt
: There is a problem with the TAB character: I can not find a way to represent
: it in a way that perl recognize.
: So I have to hack sth like:
: perl -F"\t" -lane "print $F[0], _______, log($F[1]+1)" in.txt|perl -pi -e "s
: /_______/\t/g"
: Any better ways of doing it? Thanks!

t****t
发帖数: 6806
5
bah, peng myself.

【在 X****r 的大作中提到】
: Don't you need to esacpe $ against shell?
: Under bash:
: perl -F"\t" -lane "print \$F[0], \"\t\", log(\$F[1])" infile.txt
:
: represent
: e "s

X****r
发帖数: 3557
6
你这个更加精悍些。

【在 t****t 的大作中提到】
: bah, peng myself.
s***r
发帖数: 32
7
It's windows...
I can only use " not '
Thanks anyway

【在 t****t 的大作中提到】
: it has nothing to do with tab, you are using wrong quotes (for shell)
: perl -F"\t" -lane 'print $F[0], "\t", log($F[1])' infile.txt
:
: represent
: "s

1 (共1页)
进入Programming版参与讨论
相关主题
脚本问题求教问一个perl/php问题
one question about algorithmperl question
缩进用空格好,还是tab好?请 教 : 关 于 writing to a file 用 Perl for CGI
我朋友说他一门课,老师专门教学生怎么hack,还要自己做一个hack的project.再 次 请 教 : 关 于 writing to a file 用 Perl for CGI
what is used to represent a "tab" character in "sed"一个perl bug,求救,谢谢!
这个 perl 输出的数字为什么自动加了换行?谢谢!compare double to float
How to encode YYYY-MM-DD?这个perl的简单小程序为什么不work? (转载)
入门问题,perl里s@\_@@g 是什么意思?50伪币:请教perl代码差错的问题!多谢啦!
相关话题的讨论汇总
话题: perl话题: print话题: tab话题: liner话题: log