[Bioperl-l] Problems with a while loop, please help

Mark A. Jensen maj at fortinbras.us
Mon Mar 16 11:55:36 UTC 2009


Markus:
I think you want to increment $k by 3 in the continue block; i.e., $k+=3, not 
$k++
cheers MAJ
----- Original Message ----- 
From: "manni122" <markus.liebscher at gmx.de>
To: <Bioperl-l at lists.open-bio.org>
Sent: Monday, March 16, 2009 7:29 AM
Subject: [Bioperl-l] Problems with a while loop, please help


>
> Hi there, I need a little bit help in simple programming. I have two arrays
> in which codons are stored. These arrays I need to compare. If I find
> similar codons at the same position in both arrays everything is fine, if
> not I am splitting every codon further into the bases.
>
> @zwvalue1 = split(//, $value1);
> @zwvalue2 = split(//, $value2);
>
> And then I want to compare base 1 from array 1 with base 1 from array 2 and
> so on. But if I am looking at the values from the following while loop
>
> my $k = 0;
>
> while ($k <= 2) {
> $value1a = @zwvalue1[$k];
> $value1b = @zwvalue2[$k];
> $value2a = @zwvalue1[$k+1];
> $value2b = @zwvalue2[$k+1];
> $value3a = @zwvalue1[$k+2];
> $value3b = @zwvalue2[$k+2];
>
> print "@zwvalue1, $value1a, $value2a, $value3a\n";
> }
>     continue {
>     $k++;
>
> I get as output for example:
> T A A, T, A, A
> T A A, A, A,
> T A A, A, ,
>
> Why is this loop running 3times? I just need this loop running once to
> compare all three bases at one time.
> Any help is appreciated.
> -- 
> View this message in context: 
> http://www.nabble.com/Problems-with-a-while-loop%2C-please-help-tp22536301p22536301.html
> Sent from the Perl - Bioperl-L mailing list archive at Nabble.com.
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
> 




More information about the Bioperl-l mailing list