Advertisement

Online Perl Compiler

Write, run and test Perl code online, right in your browser. This free online Perl compiler needs no installation or signup — just type your code and click Run.

Perl is a mature scripting language with powerful text processing and regular expressions, popular for system administration and report generation.

How to use the Perl compiler

  1. Write or paste your Perl code in the editor.
  2. If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
  3. Click Run — the output and any errors appear in the output panel.

Sample: read input in Perl

my $name = <STDIN>;
chomp($name);
print "Hello, $name!\n";

Paste this into the editor, type your name in the STDIN box and click Run.

More Perl examples to try

Regular expressions

Perl is famous for text processing with regular expressions.

use strict;
use warnings;

my $log = "2026-11-23 ERROR Disk full\n2026-11-23 INFO Started\n2026-11-24 ERROR Timeout";
for my $line (split /\n/, $log) {
    if ($line =~ /^(\S+) ERROR (.+)$/) {
        print "On $1: $2\n";
    }
}

Hashes and sorting

Count words with a hash and sort them by frequency.

use strict;
use warnings;

my %count;
$count{$_}++ for split /\s+/, "perl is fun and perl is fast";
for my $w (sort { $count{$b} <=> $count{$a} || $a cmp $b } keys %count) {
    print "$w: $count{$w}\n";
}

Common Perl errors and how to fix them

Global symbol "$x" requires explicit package name
With use strict, declare variables with my before using them.
Use of uninitialized value
A variable has no value — often <STDIN> returned nothing. Provide input, or check with defined.
syntax error at line N, near "}"
A semicolon is missing on the line before, or a brace does not match.
Input has a trailing newline
Lines read from <STDIN> keep their newline. Call chomp($line) before using them.

Frequently asked questions

Is this online Perl compiler free?

Yes. It is completely free to use, with no signup required to write and run code.

Do I need to install anything?

No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.

How do I give input to my Perl program?

Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.

Is this good for learning Perl?

Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.

Other online compilers

Editor powered by OneCompiler.