#!/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];
}
####
$ pm_1126327_combine_file_data.pl
=====================================
| Inbound Track 1 | Inbound Track 2 |
-------------------------------------
| B&O 101 | CSXT 1001 |
| B&O 102 | CSXT 1002 |
=====================================
####
while (1) {
last if eof $fh1;
printf $format => get_data(scalar <$fh1>), get_data(scalar <$fh2>);
}