Re: nested "if"

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 07/03/04


To: beginners@perl.org
Date: Sat, 03 Jul 2004 11:46:55 +0200

Michael S. Robeson II wrote:
> Which of the two "if" statements gets evaluated first? I am trying
> to figure out "in english" what the "if" statements are actually
> doing. Is it saying:
>
> "If a line begins with ">bla-bla" and if $seq (which appears no
> where else in the code other than " $seq="" ") exists assign it to
> the hash "pro" with the name "bla-bla"."
>
> So my question is how does the inner if statement work when seq=""
> is out side that "if" statement?

It's a while loop. For a particular iteration of the loop, $seq and
$name may contain values that were assigned to them during a
*previous* iteration, but the values that will be used in the inner
if-statement during the *current* iteration is not related to what
will happen to those variables later during this same iteration.

> Is the outer "if" statement evaluated first then the inner?

As long as we are talking about the same iteration: No.

> Because how does the inner "if" statement know what "$seq" is?

See above.

HTH

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Relevant Pages

  • Yow! LOOP macros are LOOPY!
    ... By relying entirely on procedure calls to express iteration, ... to but cleaner than C's FOR loop. ... other macros going around at the time other than MacLisp's ... (bind (vi (vector-ref v i))) ...
    (comp.lang.scheme)
  • Re: Performance: Iterating a vector in a loop..
    ... > But he was saying its slow because .beginand .endare called every ... > loop. ... > I know that the function is called every iteration, ... > any speed hits when doing that, or, if it would be better to re-write the ...
    (microsoft.public.vc.language)
  • Re: Polling, Interrupts, DMA, Synchronous, Asynchronous I/O Definitions
    ... the terminology is less useful than it might be. ... though a "message loop" could arguably be claimed to be ... considering in a particular iteration but what is true for _ALL_ ... watching the "polling" version eating up every single CPU cycle ...
    (alt.lang.asm)
  • Re: Histogram of character frequencies
    ... generated object code may simply be a loop in which elements are ... believe any C compiler anywhere would reject it. ... On the first iteration of the loop you test the end of file indicator ...
    (comp.lang.c)
  • Re: Random number help
    ... is used to generate cooccurance matrix for each iteration of for loop. ... disp('the sample co-occurance matrix is as follows');% GIVING SAME ...
    (comp.soft-sys.matlab)