BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Until loop in Perl with example

By Chaitanya Singh | Filed Under: Perl

Until loop behaves just opposite to the while loop in perl, while loop continues execution as long as the condition is true. In until loop, the loop executes as long as the condition is false.

Syntax of until loop:

until(condition)
{
   statement(s);
}

Flow of Execution of the until Loop

The condition is evaluated first, if it returns false, the statements inside loop gets executed. After execution the condition is re-evaluated. This goes on until the condition returns true. Once the condition returns true, the control gets transferred to the next statement after until loop.

Example

#!/usr/local/bin/perl

$num = 10;

until( $num >15 ){
   printf "$num\n";
   $num++;
}

Output:

10
11
12
13
14
15

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Perl Tutorial

  • Perl Tutorial
  • Perl Installation
  • First Perl Program
  • Perl Syntax
  • Data types in Perl
  • Perl Variables
  • my keyword
  • Perl Scalars
  • Use strict and use warnings
  • Perl Arrays
  • Perl Hashes
  • Operators in Perl
  • Perl Conditional statements
  • Perl if
  • Perl if-else
  • Perl if-elsif-else
  • Perl unless
  • Perl unless-else
  • Perl unless-elsif-else
  • Perl switch case
  • Perl given-when-default
  • Perl loops
  • Perl subroutines
  • Perl Strings
  • Perl Escape Sequences

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap