in reply to Re: Comparing array of aligned sequences
in thread Comparing array of aligned sequences

Thank you for your time and reply. I did some modifcations and now the program is printing 3 times each value on match. I guess I am not putting the print at the right place.

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $seqcount; my $pos; my $arrlen; my @arr = (); open (B, "temp.dat"); while (my $line=<B>) { chomp $line; $seqcount++; $line =~ s/\s//g; my @temp = split (//, $line); $arrlen = scalar(@temp); for ($pos=0;$pos<=$#temp;$pos++) { $arr[$seqcount][$pos] = $temp[$pos]; # print "$pos\t$arr[$seqcount][$pos]\n"; } } my $max_position = 0; $max_position = $arrlen if($arrlen > $max_position); for ($pos=0;$pos<=$max_position;$pos++) { for (my $s=1;$s<=$seqcount;$s++) { # print "$pos\t$s\t$arr[$s][$pos]\n"; if ($arr[$s][$pos] ne $arr[$seqcount][$pos]) { print "\n"; next; } else { print "$arr[$s][$pos]"; } } print "\n"; }
Do I need to push in another array after there is a match of values? Thanks for your help.