in reply to Matching columns between files

Welcome to the Monastery.

See: How do I compose an effective node title?.

The code you posted has compile errors. Did you mean to have an "if" to match your "else"?

You have a scoping problem. Those are two different @slice arrays.

my @slice; ... while(<INFILE1>) { chomp; my @array = split ('\t', $_); my @slice = @array[0,1,2]; }

You probably want to get rid of my inside your while loop and maybe you need to push. My guess is that your foreach loop never loops through your @slice array since it is empty.

Replies are listed 'Best First'.
Re^2: Matching columns between files
by gggg (Initiate) on Jun 25, 2011 at 21:15 UTC
    Hey Thanks for the information. I am trying here to match the three columns 0,1,2 which I sliced from the first array with the three columns 1, 2,3 of another infile and print the column 4 of second infile for the corresponding matches. I am not sure what is wrong in the code relevant to this Thanks