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

Lincoln Stein lincoln.stein at gmail.com
Mon Mar 16 18:44:30 UTC 2009


One problem is that this notation:

$value2a = @zwvalue1[$k+1];

does not do what you expect. You want this:

$value2a = $zwvalue1[$k+1];

Another problem is that you are running the loop three times: k=0, k=1, k=2.
The while loop only stops when k is no longer <= 2.

Lincoln

On Mon, Mar 16, 2009 at 7:29 AM, manni122 <markus.liebscher at gmx.de> wrote:

>
> 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
>



-- 
Lincoln D. Stein
Director, Informatics and Biocomputing Platform
Ontario Institute for Cancer Research
101 College St., Suite 800
Toronto, ON, Canada M5G0A3
416 673-8514
Assistant: Renata Musa <Renata.Musa at oicr.on.ca>



More information about the Bioperl-l mailing list