|
发表于 2020-8-20 11:09:27
|
显示全部楼层
#! /usr/bin/env perl
use 5.010;
use strict;
use warnings;
use autodie;
my %line_hash = (
0 => [],
1 => [],
2 => [],
3 => [],
);
open my $fr, "<", shift;
open my $fw, ">", shift;
my $linenum = 0;
while(<$fr>) {
chomp;
push @{$line_hash{$linenum%4}}, " ".$_;
if($linenum == 7) {
say $fw @{$line_hash{$_}} for 0..3;
undef @{$line_hash{$_}} for 0..3;
$linenum = 0;
}
else {
$linenum++;
}
}
close $fr;
close $fw;
%change.pl infile outfile
|
|