Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Comparing array of aligned sequences

by newtoperlprog (Sexton)
on Jul 11, 2014 at 17:05 UTC ( [id://1093259]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1093259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-03-28 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found