On 15/04/2011 13:48, shawn wilson wrote:
but, sense it is jumping to a different place in the stack, isn't it more efficient than doing the above mentioned my $done = 0; while( !$done ){ $done = 1 if( contition ); do_work; } vs for(;;) { goto DONE if( contition ); do_work; } label DONE; i'd think the later would be faster not only because you are jumping to a memory location and because you're not assessing a value every time.
Hi Shawn. I'm not sure what code your comparing to, but there is no stack involved here at all. The second example would be quicker, simply because you are testing the condition directly instead of transferring the state to the variable $done and then testing the variable. By the way, the loops are not equivalent, as the first executes do_work at least one, while the second may drop out immediately without doing anything at all. It would be better written: until (condition) { do_work; } Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/