#!/usr/bin/env perl -l use strict; use warnings; my $format = "| %-15s | %-15s |\n"; my $format_width = 37; print '=' x $format_width; printf $format => 'Inbound Track 1', 'Inbound Track 2'; print '-' x $format_width; my ($file1, $file2) = qw{pm_1126327_inbndtrk1.txt pm_1126327_inbndtrk2.txt}; open my $fh1, '<', $file1 or die "Can't open '$file1' for reading: $!"; open my $fh2, '<', $file2 or die "Can't open '$file2' for reading: $!"; while (<$fh1>) { printf $format => get_data($_), get_data(scalar <$fh2>); } close $fh1; close $fh2; print '=' x $format_width; sub get_data { chomp(my $line = shift); join ' ' => (split /:/ => $line)[1,2]; }