简体   繁体   English

Perl ( Print $_ ) 字符不正确 output || forparam循环

[英]Perl ( Print $_ ) Incorrect output for characters || forparam loop

I am having the below lines of perl cgi code that suppose to iterate through a file lines and print each line.我有以下 perl cgi 代码行,这些代码假设遍历文件行并打印每一行。 The issue is what is printed to the stdout for a specific line (in[ 41: ]) is not the same in the file.问题是针对特定行(in[41:])打印到标准输出的内容与文件中的内容不同。

Note: This is a perl cgi script.注意:这是一个 perl cgi 脚本。

code:代码:

for (param('menu')) {
  /^(1)$/ and do {
                        $Sample="cat /tmp/int_rej_sample.txt";
                        @Sample=`$Sample`;
                        foreach (@Sample) {print $_,p}
   }

   }

cat /tmp/int_rej_sample.txt is: cat /tmp/int_rej_sample.txt 是:

 in[ 37: ]<22222222222>
 in[ 39: ]<91>
 in[ 39: ]<91>
 in[ 41: ]<BBBBBBBB44444444>
 in[ 42: ]<9999999999     >

output to cgi window is: output 到 cgi window 是:

in[ 37: ]<22222222222>

in[ 39: ]<91>

in[ 39: ]<91>

in[ 41: ]

in[ 42: ]<9999999999 >

I have added a space between "<" and any character after it in the file before entering the print loop.That solved the issue.在进入打印循环之前,我在文件中的“<”和它后面的任何字符之间添加了一个空格。这解决了这个问题。

sed -e 's/</< /g' /tmp/int_rej_sample_dev.txt | sed -e 's/>/ >/g' > /tmp/int_rej_sample.txt
 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM