为什么Strawberry Perl不会删除这些换页字符?

dig*_*ron 0 perl flat-file strawberry-perl

我目前正在WinXP上运行Strawberry Perl,我正在尝试处理一个unix格式的平面文件.平面文件使用换行符来分隔字段,并使用换行符来分隔记录.我试图将FF转换为其他任何东西(CRLF,';',TAB等).我尝试过使用以下perl one-liners但没有成功:

perl -p -e 's/\f/\r\n/g' < unix.txt > dos.txt
perl -p -e 's/\x0c/\x0d\x0a/g' < unix.txt > dos.txt
perl -p -e 's/\f/\t/g' < unix.txt > dos.txt
Run Code Online (Sandbox Code Playgroud)

我唯一注意到的是dos.txt最终将所有LF字符转换为CRLF,但FF字符仍然存在.我甚至试图重新处理dos.txt文件,再次尝试替换FF,但仍然没有骰子.我仍然是一个perl新手,所以也许我错过了什么?有谁知道为什么上面的命令不能做我想让他们做的事情?

mob*_*mob 8

问题是Windows shell不像Unix shell那样解释单引号.您应该在命令中使用双引号.

C:\ perl -e "print qq/foo\fbar/" > test.txt
C:\ type test.txt
foo?bar
C:\ perl -pe 's/\f/__FF__/' < test.txt
foo?bar
C:\ perl -pe "s/\f/__FF__/" < test.txt
foo__FF__bar
Run Code Online (Sandbox Code Playgroud)