I have three files all one column with possibly different rows of digits. ie
file1: file2: file3: header header header 1 5 1 2 2 3 3 3 3 4 4 4 5 6 5Remember, these are three seperate files. Now, what I need to do is get those values from each row in each file into one list with each value delimited by a pipe "|" and stripped of the header. BUT WAIT! It gets more cumbersome. Evaluation needs to be done on a line by line basis to determine if each field matches each other and if they don't match then the field for that column/row combo is left blank.
My biggest problem right now is what I want to do may not work. I'd like to populate the arrays and then somehow compare each element in each array to each other on a row by row basis...if a given two elements don't match between two arrays bump the lower element value of the two element values in the comparison into the next elemental slot in its array (subsequently bumping all elements in that array up one).#!/usr/local/bin/perl -w use strict; my (@list1, @list2, @list3, $c); open(F1,"f1.lst"); open(F2,"f2.lst"); open(F3,"f3.lst"); # Populate the arrays $c = 0; while ( <F1> ) { next if ( $c == 0 ) and $c++; # skip the file header chomp; $list1[$c++] = "$_ |" ; }; close(F1); $c = 0; while ( <F2> ) { next if ( $c == 0 ) and $c++; # skip the file header chomp; $list2[$c++] = "$_ |" ; } close(F2); $c = 0; while ( <F3> ) { next if ( $c == 0 ) and $c++; # skip the file header chomp; $list3[$c++] = "$_ |" ; } close(F3); I have no clue where to begin...
The output would be similar to this:
final file: 1 | | 1 2 | 2 | 3 | 3 | 3 4 | 4 | 4 5 | | 5 | 6 |The comparison would be like this:
compare list1 row1 to list2 row1 if match go on, if !match (perform element bump here)
compare list2 row1 to list3 row1 if match go on, if !match (perform element bump here)
compare list1 row2 to list2 row2 if match go on, if !match (perform element bump here)
.
.
.
etc
The input has no need to be sorted as the files are already sorted. I believe I am on a right track but by all means no where near the most efficient track which is my goal. I have been working on code all day and so my mind is fried right now. With my luck, I will think of a solution on the way home. I apologize if this question is not worthy of attention :)
TIA fellow monks.
----------
- Jim
In reply to Printing out multiple array lists and more! by snafu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |