Welcome to WebmasterWorld Guest from 54.242.134.77

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Break doesn't break

Keeps executing after the break statement

     

MichaelBluejay

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

WebmasterWorld Senior Member 10+ Year Member



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?

pinterface

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

5+ Year Member



break [perldoc.perl.org] doesn't do what you think it does. You probably want last [perldoc.perl.org].

MichaelBluejay

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

WebmasterWorld Senior Member 10+ Year Member



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. :)

rocknbil

10:03 pm on Jun 19, 2010 (gmt 0)

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



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

Featured Threads

Hot Threads This Week

Hot Threads This Month