#!usr/bin/perl use strict; use warnings; use Data::Dumper; my @final; while (<>) { # Read all files that provided through ARGV chomp; my @tmp = split / /, $_; # print Dumper \@tmp; my $first = unpack 'a', $tmp[0]; push @final, join(' ', $first, $tmp[2], $tmp[3]); } continue { close ARGV if eof; # reset $. each file } print Dumper \@final; __END__ $ perl test.pl in.txt $VAR1 = [ 'A 1 violation', 'A 4 violations', 'B 3 violations' ]; __DATA__ A_01: xxxxxxxxxxxxxxxxxxxx......... 1 violation A_02: xxxxxxxxxxxxxxxxxxxx......... 4 violations B_02: xxxxxxxxxxxxxxxxxxxx......... 3 violations