in reply to Re: Two Column Data
in thread Two Column Data

Yes, the data has already been put into the arrays and the data from file 1 needs to be in column one and data from file 2 needs to be in column 2. My issue has to do with column formats.

Replies are listed 'Best First'.
Re^3: Two Column Data
by Laurent_R (Canon) on May 11, 2015 at 19:44 UTC
    What you want to do is still not clear to me.
    the data from file 1 needs to be in column one and data from file 2 needs to be in column 2
    Yes, but your code seems to be splitting the data from both files. Do you want only one part of the data from both files? If so, which one?

    Do you files have the same numbers of elements and can it be assumed that we can just marry the nth line of file 1 with nth line of file 2 to produce the nth line of the output file?

    Je suis Charlie.

      The desired output should be this:
      =====================
      TRACK 1 | TRACK 2
      =====================
      B&O 101 | CSXT 1001
      =====================
      The data from File 1 needs to be in column 1 and the data from File 2 needs to be in column 2

        OK, here is one way to do it:
        print "=====================================\n"); print "| INBOUND TRACK 1 | INBOUND TRACK 2 |\n"); print "=====================================\n"); open my $IN1, "<", "inbndtrk1.txt" or die "could not open inbndtrk1.tx +t" ; open my $IN2, "<", "inbndtrk2.txt" or die "could not open inbndtrk2.tx +t" ; while (my $in1 = <$IN1>) { chomp $in1; $in1 = s/:/ /; my $in2 = <$IN2>; $in2 = s/:/ /; print "$in1|$in2"; }
        Note that you have a slight discrepancy between the header and the data: your code for the header uses three "|" symbols, but the output result that you are looking for does not. I'll leave it to you to sort out what you really want, but feel free to ask if you encounter any difficulty, or if you don't understand something from the above code. Also note that this is untested, as I have not real test data.

        Update: Oops, stupid error on my part, thanks to AnomalousMonk for pointing out. The loop code should be:

        while (my $in1 = <$IN1>) { chomp $in1; $in1 =~ s/:/ /; my $in2 = <$IN2>; $in2 =~ s/:/ /; print "$in1|$in2"; }

        Je suis Charlie.
Re^3: Two Column Data
by Laurent_R (Canon) on May 11, 2015 at 19:36 UTC
    Please do not change your original post after you have received some answers, or if you do, please indicate clearly with an update tag what you have added. You are now making me look as a fool because I asked questions whose answers appear to be in the original post, but were not there when I asked the questions.

    Update: Thank you for having now marked your updates and having done so quickly.

    Je suis Charlie.