Welcome to WebmasterWorld Guest from 54.225.33.25

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Break doesn't break

Keeps executing after the break statement

     
6:34 pm on Jun 18, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 0


for $counter (0..100) { 
if ($counter==50) { $match=1;}
if ($match) { break; print "Executing after break";}
}

I run this and "Executing after break" prints 50 times.

What am I missing?
6:45 pm on June 18, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 28, 2006
posts:96
votes: 0


break [perldoc.perl.org] doesn't do what you think it does. You probably want last [perldoc.perl.org].
6:51 pm on June 18, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts:1199
votes: 0


Ugh--that's what I get for programming when I'm sleepy.

C="break;", Perl="last;"
C="continue;", Perl="next;"

Anyway, thanks for waking me up. :)
10:03 pm on June 19, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


And . . . PHP="break". :-)