vyeddula has asked for the wisdom of the Perl Monks concerning the following question:
do { $i=0; print"the value of i inside the loop is :$i\n"; $i++; }until($i<=10)
On executing above script i am getting output the value of i inside the loop is :0 .I am expecting the loop should execute.Please clarify
Case2:use strict; my $i=5; do { print"the value of i is :$i\n"; $i--; }until($i<=0);
This program is executing as expected
Case3:use strict; my $i=5; print "the value of i outside the loop is $i\n"; do { print"now i entered inside the loop \n"; my $i=10; print "the value of i inside the loop is :$i\n"; $i--; }until($i<=0);
This is failing to go through the loop. Please clarify why scoping inside the loop is not getting triggered.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: scoping inside the loop
by LanX (Saint) on May 17, 2013 at 17:59 UTC | |
by Anonymous Monk on May 17, 2013 at 18:36 UTC | |
by LanX (Saint) on May 17, 2013 at 18:40 UTC | |
|
Re: scoping inside the loop
by hdb (Monsignor) on May 17, 2013 at 19:00 UTC | |
by LanX (Saint) on May 17, 2013 at 19:06 UTC | |
by Anonymous Monk on May 17, 2013 at 21:55 UTC |