I have just started learning Perl scripting language and have a question.
In Perl, what is the logical reason for having continue block work with while and do while loops, but not with for loop?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use a
continueblock everywhere it makes sense: withwhile,untilandforeachloops, as well as ‘basic’ blocks — blocks that aren’t part of another statement. Note that you can use the keywordforinstead offoreachfor the list iteration construct, and of course you can have acontinueblock in that case.As everybody else said,
for (;;)loops already have acontinuepart — which one would you want to execute first?continueblocks also don’t work withdo { ... } while ...because syntactically that’s a very different thing (dois a builtin function taking a BLOCK as its argument, and thewhilepart is a statement modifier). I suppose you could use the double curly construct with them (basic block inside argument block), if you really had to: