in reply to last in a do while loop
does not compile, since the do does not know anything about the while.
So it compiles just fine.
~/perl$ cat x
last if bob;
} while (alice);
~/perl$ perl -c x
x syntax OK
~/perl$ perl -v
This is perl, v5.6.1 built for i386-linux
What is not working, though, is the last. This is because the block introduced with do is neither a loop nor a bare block. Your statement is basically equivalent in structure to print foo while bar.
What you can do instead is a bare block, because you can use next, last, redo on a bare block:
last LOOP if bob;
redo LOOP if alice;
Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.