perl

The Perl 5 language interpreter. More information: <https://www.perl.org>.

Install

All systems
curl cmd.cat/perl.sh
Debian Debian
apt-get install perl-base
Ubuntu
apt-get install perl-base
Alpine
apk add perl
Arch Arch Linux
pacman -S perl
image/svg+xml Kali Linux
apt-get install perl-base
CentOS
yum install perl-base
Fedora
dnf install perl-base
Windows (WSL2)
sudo apt-get update sudo apt-get install perl-base
OS X
brew install perl
Raspbian
apt-get install perl-base
Docker
docker run cmd.cat/perl perl powered by Commando

The Perl 5 language interpreter. More information: <https://www.perl.org>.

  • Parse and execute a Perl script:
    perl script.pl
  • Check syntax errors on a Perl script:
    perl -c script.pl
  • Parse and execute a Perl statement:
    perl -e perl_statement
  • Run a Perl script in debug mode, using `perldebug`:
    perl -d script.pl
  • Edit all file lines [i]n-place with a specific replacement [e]xpression, saving a backup with a new extension:
    perl -p -i'.extension' -e 's/regular_expression/replacement/g' path/to/file
  • Run a multi-line replacement [e]xpression on a file, and save the result in a specific file:
    perl -p -e 's/foo\nbar/foobar/g' path/to/input_file > path/to/output_file
  • Run a regular [e]xpression on `stdin`, printing matching [l]ines:
    cat path/to/file | perl -n -l -e 'print if /regular_expression/'
  • Run a regular [e]xpression on `stdin`, printing only the first capture group for each matching [l]ine:
    cat path/to/file | perl -n -l -e 'print $1 if /before(regular_expression)after/'

© tl;dr; authors and contributors