HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to PerlOperatorsStringsArrays (@)Hashes (%)Conditions (if)LoopsFunctions (sub)
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
✍️ Text & Number
📋 Array & Hash
🔁 Condition & Loop
if / elsif / elseforeach / forwhile
🧩 Function (sub)
Perl›REFERENCE›Condition & Loop›if / elsif / else

if / elsif / else

Executes code based on a condition.

Syntax

if (condition) { } elsif { } else { }

Description

Blocks are inside { }. Number comparison is == != < >; text comparison is eq ne lt gt. unless is the reverse condition.

Example

Loading editor…

Expected output

Passed

When to use?

Flow branching.

Common mistakes

  • ⚠️ Number equality uses ==, TEXT equality uses eq (they are different!).

Related commands

foreach / forwhile
foreach / for →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code