"jeniffer" <> wrote in
news: oups.com:
>
> John W. Krahn wrote:
>> jeniffer wrote:
>> > i read that last doesnt work inside a do while loop.Then how to
>> > break out from a do-while loop...
>> > do{
>> > if(some condition)
>> > {
>> > last;
>> > }
>> >
>> > }while(condition)
>>
>> What you want to do is described in the "Statement Modifiers" section
>> of the perlsyn document.
>>
>> perldoc perlsyn
snip quoted sig ... don't do that.
> I did the following:
>
> LOOP: {
> do {
> last if (condition)
> {
> print "exit message";
> }
> # do something here
> } while (condition2);
> }
>
>
> but again it does not work
Post a short but complete script that demonstrates the problem. When
posting code, use proper indentation to make it easier for others to
read your code.
D:\Home\asu1\UseNet\clpmisc> cat brk.pl
#!/usr/bin/perl
use strict;
use warnings;
my $x = 10;
LOOP: {
do {
--$x;
last LOOP if 0.5 < rand 1;
} while ( $x );
}
print "\$x = $x\n";
D:\Home\asu1\UseNet\clpmisc> brk
$x = 7
Sinan
--
A. Sinan Unur <>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html