vis1982 has asked for the wisdom of the Perl Monks concerning the following question:
And another Second file shows pairingA1 A2 A3 A4 A1 A2 A3 A4
Want the output to be like based on the pairing .. As seen from the second fileThose who are paired will get one A1 A4 will get one same with A1 A3 will get one A1 A2 willw get zero The output shud be like thatA1;A4 A2;A3 A2;A4 A1;A3
The code isA1 A2 A3 A4 A1 0 0 1 1 A2 0 0 1 1 A3 1 1 0 0 A4 1 1 0 0
But i didn't get how to create a matrix with that one?#!/usr/bin/perl $data_file="aa1"; open(DAT, $data_file) || die("Could not open file!"); @raw_data=<DAT>; close(DAT); #print $raw_data[0]; $data_file2="aa2"; open(THAT, $data_file2) || die("Could not open file!"); @raw2_data=<THAT>; close(THAT); foreach $data (@raw2_data) { @siv =split(";",$data); if (($siv[0])== ($siv[1])) { print "1"; } else { print "0"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: create a matrix for print 0 or 1 from pairing
by moritz (Cardinal) on Oct 28, 2009 at 11:38 UTC | |
|
Re: create a matrix for print 0 or 1 from pairing
by Perlbotics (Archbishop) on Oct 28, 2009 at 12:21 UTC | |
by vis1982 (Acolyte) on Oct 28, 2009 at 16:48 UTC | |
by vis1982 (Acolyte) on Oct 29, 2009 at 09:26 UTC | |
by jakobi (Pilgrim) on Oct 29, 2009 at 09:48 UTC |