Linux 防止Perl程序在使用系统写入sh终端后打印换行符
我试图将数据从一个文件提取到一个Perl程序中,并在LinuxSH终端中使用“foreach”循环执行它,但每次Perl将值返回到sh终端时,它都会在打印下一个字符串之前打印一行,这会导致我的脚本失败。我如何防止这种情况Linux 防止Perl程序在使用系统写入sh终端后打印换行符,linux,bash,shell,perl,Linux,Bash,Shell,Perl,我试图将数据从一个文件提取到一个Perl程序中,并在LinuxSH终端中使用“foreach”循环执行它,但每次Perl将值返回到sh终端时,它都会在打印下一个字符串之前打印一行,这会导致我的脚本失败。我如何防止这种情况 open(FILE, "input") or die("Unable to open file"); # read file into an array @data = <FILE>; # close file close(FILE); foreach my
open(FILE, "input") or die("Unable to open file");
# read file into an array
@data = <FILE>;
# close file
close(FILE);
foreach my $x(@data) {
system "/granite_api.pl -type update_backdoor -project tgplp -test_id $x -turninid 4206";
}
实际产量:
/granite_api.pl -type update_backdoor -project tgplp -test_id example
-turninid 4206
与
参见
chomp
也适用于列表:chomp(@data)
将咀嚼@data
中的所有元素。
/granite_api.pl -type update_backdoor -project tgplp -test_id example
-turninid 4206
@data = <FILE>;
foreach my $x ( @data ) {
chomp $x;
system "/granite_api.pl -type update_backdoor -project tgplp -test_id $x -turninid 4206";
}