gpt4 book ai didi

perl - perl 脚本中的粘贴和 awk 错误

转载 作者:行者123 更新时间:2023-12-01 05:02:09 25 4
gpt4 key购买 nike

我用过

paste Output1.txt Output2.txt | awk '{print $1, $2, $5, $15}' 

使用系统(awk_commamd)在 perl 脚本中。我收到类似

的错误
awk: {print , , , }
awk: ^ syntax error

需要帮助来解决这个错误

最佳答案

使用纯 perl 复制 pasteawk 的工作:

use strict;
use warnings;
use autodie;

my @fhs = map {open my $fh, '<', $_; $fh} qw(Output1.txt Output2.txt);

while (grep {!eof $_} @fhs) {
my @lines = map {(scalar <$_>) // ''} @fhs;
chomp @lines;
my @fields = split ' ', join "\t", @lines;

print join("\t", grep defined, @fields[0,1,4,14]), "\n";
}

关于perl - perl 脚本中的粘贴和 awk 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23603495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com