beginnersbook.com

  • Home
  • All Tutorials
    • Learn Servlet
    • Learn JSP
    • Learn JSTL
    • Learn C
    • Learn C++
    • Learn MongoDB
    • Learn XML
    • Learn Python
    • Learn Perl
    • Learn Kotlin
  • Core Java
  • OOPs
  • Collections
  • Java I/O
  • JSON
  • DBMS

Unless statement in Perl

By Chaitanya Singh | Filed Under: Perl

unless statement in perl behaves just opposite to the if statement in perl. It executes the set of statements inside its body when the given condition is false.

unless(condition) {
   statement(s);
}

The statements inside unless body would execute when the condition is false.

Example

#!/usr/local/bin/perl

printf "Enter any number:";
$num = <STDIN>;
unless($num>=100) {
   printf "num is less than 100\n";
}

Output:

Enter any number:99
num is less than 100

Enjoyed this post? Try these related posts

  1. For loop in Perl with example
  2. Switch Case in Perl
  3. Perl Tutorial for beginners
  4. Perl Variables
  5. Use strict and use warnings in Perl
  6. unless-else statement in Perl

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

Recently Added..

  • JSON Tutorial
  • Java Regular Expressions Tutorial
  • Java Enum Tutorial
  • Java Annotations Tutorial

Copyright © 2012 – 2021 BeginnersBook . Privacy Policy . Sitemap