in reply to Re^4: flip flop operator and if statement
in thread flip flop operator and if statement

> shouldnt the value of p in every iteration increment by one?

In your OP you already showed that it does.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

  • Comment on Re^5: flip flop operator and if statement

Replies are listed 'Best First'.
Re^6: flip flop operator and if statement
by iThunder (Beadle) on Sep 20, 2014 at 08:07 UTC

    it prints 3 for every iteration i.e.

    #!/usr/bin/perl ##use warnings; while(<>){ if(($p=3)..5) { print "p is $p\n"; } }

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

    p is 3

      In this code you are obviously always assigning 3.

      What's the problem?

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

        Hi Rolf,

        i am trying to understand how these two statements

        if($p=3..5)

        vs

        if(($p=3)..5)

        are interpreted inside while loop of the code?

        Thanks