open 管道用法|Getopt::Long

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

my ($number,$in,$out);
GetOptions(
    "number:i"=>$number,
    "in:s"=>$in,
    "out:s"=>$out
);

#my $all = $number +1;print $all;

open IN,"gzip -cd $in|";

open OUT,"|cat >>$out";

while (<IN>)
{
    print OUT "$_";
}

#$ perl t.pl -in 1.txt.gz -out output

#$ less 1.txt.gz 
#11111111111111111111
#yyyyyyy
#jjjjjjjjjjj
#nnnnnnnnnnnnnnn
#111111111111111111111

#$ cat output
#11111111111111111111
#yyyyyyy
#jjjjjjjjjjj
#nnnnnnnnnnnnnnn
#111111111111111111111
原文地址:https://www.cnblogs.com/yuanjingnan/p/11162739.html