Good Afternoon Esteemed Monks!

My question is simple and the code is posted below for review. I have 2 data files and 2 columns and the data from one file needs to be output to one column and the data from file two needs to be output to the second column. Now my question is in order to accomplish this do I need to have a while loop instead of 2 foreach loops? Or can I have 1 for each loop and a two column formatted output? I'm a bit confused. Thanks in advance!

UPDATED
open(MYINPUTFILEONE, "inbndtrk1.txt"); open(MYINPUTFILETWO, "inbndtrk2.txt"); $| = 1; my @linesone = <MYINPUTFILEONE>; my @linestwo = <MYINPUTFILETWO>; close (MYINPUTFILEONE); close (MYINPUTFILETWO);
End Update
printf ("%-15s %-15s\n", "================================="); printf ("%-15s %-15s\n", "| INBOUND TRACK 1 | INBOUND TRACK 2 |"); printf ("%-15s %-15s\n", "=====================================\n"); foreach (@linesone) { chomp; my @field = split(":"); my $format = "%-5s %-6s\n"; printf ($format, $field[1], $field[2]); } foreach (@linestwo) { chomp; my @field2 = split(":"); my $format2 = "%-5s %-6s\n"; printf ($format2, $field2[1], $field2[2]);

OR the foreach loops can be combined

foreach (@linesone, @linestwo) { chomp; my @field2 = split(":"); my $format2 = "%-5s %-6s\n"; printf ($format2, $field2[1], $field2[2]);
UPDATE
__DATA__ 1:B&O:101 2:B&O:102 __DATA__ 1:CSXT:1001 2:CSXT:1002

In reply to Two Column Data by PilotinControl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.