Learnr

Learn Perl

Process text, glue systems together and read the scripts that run them.

Free to start. No credit card. Or browse all courses.

What's inside your Perl course

A sample path Learnr builds for Perl. Your real course adapts to your goal and level.

  1. Running Perl, strict and warnings
  2. Scalars, arrays, hashes and context
  3. Regular expressions and text processing
  4. Files, references and nested data
  5. Subroutines, modules and CPAN
  6. One-liners, testing and maintaining old scripts

Perl is a high-level scripting language created by Larry Wall in 1987, famous for text processing and its built-in regular expressions. Variables carry sigils that show their type: $ for scalars, @ for arrays and % for hashes. Expressions behave differently in scalar or list context, which is the idea newcomers most need to learn. Perl still runs system administration scripts, bioinformatics pipelines and older web applications, and CPAN offers a huge library of modules. It is also great for one-liners that edit files from the command line. Learnr builds a personalized Perl course and teaches it through short, interactive lessons.

How to learn Perl, step by step

  1. Start every script with strict and warnings. Put use strict; and use warnings; at the top of every file and declare variables with my. These two lines catch typos and unsafe habits that make old Perl code notoriously hard to debug.
  2. Learn sigils, data types and context. Practice $scalar, @array and %hash, and how $array[0] uses a $ because one element is a scalar. Then test context: assign an array to a scalar and see you get its length.
  3. Practice regular expressions on real text. Parse a log file with m//, capture fields with parentheses, and rewrite lines with s///. Perl's regex syntax became the model for many other languages, so this skill pays off everywhere.
  4. Use references for nested data. Build a hash of arrays or an array of hashes with references, and read them with arrow syntax like $data->{users}[0]. Data::Dumper prints any structure so you can see what you built.
  5. Write modules and use CPAN. Split code into packages, install modules with cpanm, and read their docs with perldoc. Write tests with Test::More so changes to old scripts do not break the jobs that depend on them.
  6. Master command-line one-liners. Learn the -e, -n, -p and -i flags to search and edit files in place, a fast replacement for long sed and awk chains. A short daily Learnr lesson keeps sigils and context rules fresh.

What you'll learn

  • Write scripts with scalars, arrays, hashes and control flow
  • Explain scalar versus list context and predict results
  • Match, capture and substitute text with Perl regular expressions
  • Read and write files and build data structures with references
  • Install CPAN modules and write tested, modular code

How long does it take to learn Perl?

If you know another scripting language, you can write useful Perl scripts in 2 to 4 weeks at a few hours a week. Comfort with references, context and reading other people's dense code usually takes 2 to 3 months.

What you need before you start

Basic command-line use on Linux or macOS. Experience with any programming language helps, and some familiarity with regular expressions is a bonus but not required.

Common mistakes to avoid

  • Skipping use strict and use warnings, which lets misspelled variables silently become new globals and hides real bugs.
  • Ignoring context and being surprised when an array returns its length. Learn which operations impose scalar or list context.
  • Writing clever one-line regexes nobody can read later. Use the /x modifier with comments for anything complex that you will maintain.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn Perl, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full Perl course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

Perl questions, answered

Is Perl still used?

Yes, mainly in system administration, text processing, bioinformatics and maintaining established applications. Many companies run Perl scripts that someone needs to understand and update.

What is the difference between Perl and Raku?

Raku began as Perl 6 and was renamed in 2019 because it became a separate language. Perl 5 continues to be developed, and when people say Perl they usually mean it.

Should I learn Perl or Python?

For a first language, Python is usually the easier choice. Learn Perl when you need to maintain existing Perl code or want its strong text-processing one-liners.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn Perl?

Start your free, personalized Perl course in seconds. It will be typed in and ready when you get there.

Start learning Perl

Free to start. No credit card.