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
🧩 Function (sub)
Perl›Introduction to Perl

Introduction to Perl

First step into Perl, the powerful text-processing language: print, variables ($), and string interpolation.

Simple enough for a 5-year-old to understand

Print with print

First script's
1
print "Hello!\n";
Author; \n for a new line.
Output / InputAuthor; \n for a new line.
Output / Input
💡 Hint: Newlines are not automatic in Perl; you must add \n.

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (2 left)

1.Which symbol (sigil) does a single (scalar) variable start with in Perl?
2.Print exactly Hello World to the screen.

🎯 Expected output: Hello World

Loading editor…

About this topic

Perl was written in 1987 by Larry Wall to make text processing tasks easier. It was the main tool for system administrators and web developers for many years; its nickname "the duct tape of the internet" dates back to this era.

Perl's philosophy is summarized by the phrase "there's more than one way to do it". This flexibility makes the language powerful, but leaves readability up to the programmer's discipline. Two Perl scripts that do the same thing may look completely different.

Perl's strongest feature is that regular expressions are built directly into the language. Searching and replacing text, parsing log files, and converting formats are one-line jobs in Perl. Even today, many system scripts are written in Perl for this very reason.

What you will learn

  • How a Perl script works
  • printing to the screen with print
  • The necessity of the newline character
  • Using strict and warnings
  • Writing comment lines

Who is this for?

  • Those who do system administration
  • Those who need to parse log files and text
  • Those who need to maintain legacy Perl code

When to use?

Perl is still a very efficient tool for text processing, log analysis, and quick system scripts; the things that can be done with one-liner commands are impressive.

It is not preferred today for new web applications or large team projects; Python is more readable and has a broader ecosystem.

Common mistakes

Wrong

print "Hello"

Every statement in Perl ends with a semicolon; this code gives a "syntax error". Also, print does not add a newline; you need to write an escape sequence at the end of the output to move to the next line. These two missing things together are the first trap for beginners.

Correct

print "Hello\n";

Wrong

$sayi = 10;
print $sayy;

On the second line, the variable name is misspelled, but Perl does not consider this an error with default settings; the undefined variable is printed as an empty value and nothing is written to the screen. Silent errors like this waste hours when strict and warnings are not used.

Correct

use strict;
use warnings;
my $sayi = 10;
print $sayi;

Wrong

use strict;
$toplam = 5;
print $toplam;

When strict is enabled, variables must be declared with my; this code gives the error "Global symbol \"\$toplam\" requires explicit package name". Although the error looks annoying, its purpose is to catch typos at compile time.

Correct

use strict;
my $toplam = 5;
print $toplam;

Frequently asked questions

Why should strict and warnings be in every script?

Together, they turn off Perl's most dangerous flexibilities: they turn undeclared variables and suspicious conversions into errors or warnings. In the Perl community, these two lines are the undisputed standard and must be present in new code.

Are Perl 5 and Perl 6 the same language?

No. Perl 6 evolved so differently that it eventually became a separate language named Raku. Today, when "Perl" is mentioned, it refers to Perl 5, which is actively maintained.

What does the shebang line do?

It tells the system which interpreter to use when you run the script directly. It is not needed if you pass the file as an argument to the perl command, but it is standard for executable scripts.

Summary

Every statement ends with a semicolon.

print does not add a newline.

strict and warnings must be in every script.

When strict is enabled, variables are declared with my.

Perl is very powerful at text processing.

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