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

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.

Replies are listed 'Best First'.
Re^4: Two Column Data
by PilotinControl (Pilgrim) on May 11, 2015 at 19:54 UTC

    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.

        Does not show anything even when there is data in the files...all it shows is the "| |" when executed.