Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:41:37+00:00 2026-06-10T05:41:37+00:00

Quick Perl question: when going through a loop (say a while loop), what is

  • 0

Quick Perl question: when going through a loop (say a while loop), what is the difference between a next and continue command? I thought both just skip to the next iteration of the loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:41:38+00:00Added an answer on June 10, 2026 at 5:41 am

    The continue keyword can be used after the block of a loop. The code in the continue block is executed before the next iteration (before the loop condition is evaluated). It does not affect the control-flow.

    my $i = 0;
    when (1) {
      print $i, "\n";
    }
    continue {
      if ($i < 10) {
        $i++;
      } else {
        last;
      }
    }
    

    Is almost equivalent to

    foreach my $i (0 .. 10){
      print $i, "\n";
    }
    

    The continue keyword has another meaning in the given–when construct, Perl’s switch–case. After a when block is executed, Perl automatically breaks because most programs do that anyway. If you want to fall through to the next cases the continue has to be used. Here, continue modifies the control flow.

    given ("abc") {
      when (/z/) {
        print qq{Found a "z"\n};
        continue;
      }
      when (/a/) {
        print qq{Found a "a"\n};
        continue;
      }
      when (/b/) {
        print qq{Found a "b"\n};
        continue;
      }
    }
    

    Will print

    Found a "a"
    Found a "b"
    

    The next keyword is only available in loops and causes a new iteration incl. re-evaluation of the loop condition. redo jumps to the beginning of a loop block. The loop condition is not evaluated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question, has anyone done a benchmark on random number generation between javascript and
New to OOP with Perl, and just had a quick question. I have this
Alrighty, coding in Perl and just had a quick question. I have class created
Quick Question Lets say I have $colname = 'offer_id'; and then I want to
Quick question - i'm going to add a sitemap to a site I've designed
Here's a quick Perl question: How can I convert HTML special characters like &uuml;
Quick question, Is there a way to pipe a command into another command via
I wrote a quick Perl script to query the local DNS servers for an
Quick question, I have the following string which is a coma separated list of
Quick question. If i am trying to clear multiple divs with the same class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.