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

Conditional Statements in Perl

Last Updated: May 15, 2017 by Chaitanya Singh | Filed Under: Perl

In any programming language, conditional statements are considered as one of the most useful feature. Conditional statements are used, when we need to perform different actions depending on whether the specified condition evaluates to true or false. In perl, we have following conditional statements. Click on the links below to read a statement in detail with example.

  • if statement – If statement consists a condition, if the condition evaluates to true then the statements inside “if” execute else they do not execute
  • if-else statement – if statement has an optional else statement, if the condition specified in if statement evaluates to true then the statements inside “if” execute else the statements inside “else” execute
  • if-elsif-else statement – This is used when we need to check multiple conditions, there can be more than than one “elsif” statements in this construct.
  • unless statement – This behaves just opposite to the “if statement”. This statements inside “unless” gets executed when the specified condition returns false.
  • unless-else statement – if the condition specified in “unless” statement evaluates to false then the statements inside “unless” execute else the statements inside “else” execute
  • unless-elsif-else statement – Used for multiple conditions check
  • switch case statement – It is deprecated since Perl 5.10
  • given-when-default statement – It is a replacement of switch case
❮ PreviousNext ❯

Top Related Articles:

  1. Perl Tutorial for beginners
  2. Installing Perl on Windows, Mac, Linux and Unix
  3. If else statement in Perl
  4. unless-else statement in Perl
  5. Perl Variables

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

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 – 2025 BeginnersBook . Privacy Policy . Sitemap