Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 防止Perl程序在使用系统写入sh终端后打印换行符_Linux_Bash_Shell_Perl - Fatal编程技术网

Linux 防止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

我试图将数据从一个文件提取到一个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 $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";
}