0
我在我的perl脚本中加载和打印制表符分隔的文件。然而,我的输入文件($ table1)的最后一列是空的,我不想在我的输出文件($ table3)中打印这个。我该如何以及在哪里做这件事? '打开'后或在'print $ table3'结束后?perl删除制表符分隔文件的最后一列
这是我的脚本的一部分(...表示不代码重要的这个问题)
#! /usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
local $Data::Dumper::Useqq = 1;
use Getopt::Long qw(GetOptions);;
...
open(my $table1,'<', $input) or die "$! - [$input]"; #input file
open(my $table3, '+>', $output) || die ("Can't write new file: $!"); #output file
...
chomp(my @header_for_table1 = split /\t/, <$table1>);
print $table3 join "\t", @header_for_table1, "name1", "name2", "\n";
{
no warnings 'uninitialized';
while(<$table1>){
chomp;
my %row;
@row{@header_for_table1} = split /\t/;
print $table3 join ("\t", @row{@header_for_table1},
@{ $lookup{ ... }
// [ "", "" ] }), "\n";
}
}