我需要编写一个 perl 脚本来从其路径的文本文件列表中读取 gzip 文件,然后将它们连接在一起并输出到一个新的 gzip 文件。(我需要在 perl 中执行此操作,因为它将在管道中实现) 我不确定如何完成 zcat 和连接部分,因为文件大小将以 Gbs 为单位,我需要注意存储和运行时间也是。
到目前为止,我可以将其视为-
use strict;
use warnings;
use IO::Compress::Gzip qw(gzip $GzipError) ;
#-------check the input file specified-------------#
$num_args = $#ARGV + 1;
if ($num_args != 1) {
print "\nUsage: name.pl Filelist.txt \n";
exit;
$file_list = $ARGV[0];
#-------------Read the file into arrray-------------#
my @fastqc_files; #Array that contains gzipped files
use File::Slurp;
my @fastqc_files = $file_list;
#-------use the zcat over the array contents
my $outputfile = "combined.txt"
open(my $combined_file, '>', $outputfile) or die "Could not open file '$outputfile' $!";
for my $fastqc_file (@fastqc_files) {
open(IN, sprintf("zcat %s |", $fastqc_file))
or die("Can't open pipe from command 'zcat $fastqc_file' : $!\n");
while (<IN>) {
while ( my $line = IN ) {
print $outputfile $line ;
}
}
close(IN);
my $Final_combied_zip = new IO::Compress::Gzip($combined_file);
or die "gzip failed: $GzipError\n";
不知何故,我无法让它运行。另外,如果有人可以指导输出此压缩文件的正确方法。
谢谢!