#!/usr/bin/perl use strict; use warnings; use Text::Table; use Data::Dumper; use List::Util qw{max}; use Fcntl qw(:flock); # import LOCK_* and SEEK_END constants $| = 1; my (@result , @values , @array); sub array_sub { foreach my $arg (@_) { open (READ, "<" , $arg) or die ("Could not open: ".$arg." - $!\n"); flock(READ, LOCK_EX) or die "Could not lock '".$arg."' - $!\n"; if (-z "".$arg."") { print "File '".$arg."' is empty!\n"; # -z File has zero size (is empty). } my @doc_read = ; chomp @doc_read; foreach $_ (@doc_read) { @result = split (':', $_); if (/^\s*$/) { # /^\s*$/ check for "blank" lines may contain spaces or tabs next; } push @values, $result[3]; # get timestamp } # push an array to another to create 2-dimentional array push (@array, [@values]); @values = (); close (READ) or die ("Could not close: ".$arg." - $!\n"); } my $max_idx = max map $#$_, @array; =table structure If no columns are specified, the number of columns is taken from the first line of data added to the table. The effect is as if you had specified Text::Table->new( ( '') x $n), where $n is the number of columns. =cut my $tb = Text::Table->new; =loop values $i = maximum number or array values $_ = maximym number of characters =cut foreach my $i (0 .. $max_idx) { $tb->add( map $array[$_][$i], 0 .. $#array); } return $tb; } my $a_table = array_sub(@ARGV); print $a_table;