homepage Welcome to WebmasterWorld Guest from 54.166.173.147
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Break doesn't break
Keeps executing after the break statement
MichaelBluejay




msg:4154990
 6:34 pm on Jun 18, 2010 (gmt 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?

 

pinterface




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

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

MichaelBluejay




msg:4154997
 6:51 pm on Jun 18, 2010 (gmt 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. :)

rocknbil




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved