How To Find Out Perl Version

How do I find out Perl version by running a cgi script from a webbrowser? How can I find out Perl version from a command prompt under Windows OR Linux / UNIX OR Apple MAC OS X operating systems?

Perl is acronym for Practical Extraction and Report Language. It is a general-purpose programming language invented in 1987 by Larry Wall. Originally developed for text manipulation. Perl has become extremely popular and is now used for a wide range of tasks, including web development and interface design. This page explains how to check Perl version using various methods.

Find Out Perl Version From a Linux / Unix / BSD / OS X Shell Prompt

If you have access to a shell prompt (UNIX/Linux/macOS/BSD) type the following command to find out perl version:
$ perl -v
Sample outputs:

This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi(with 53 registered patches, see perl -V for more detail)

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at, the Perl Home Page.

You can also type above command under Windows / Mac OS X by opening terminal.

Find Perl Version Using a CGI Script

If your web hosting provider don’t provide access to a shell, use the following perl program to find out perl version:

Short version that avoid starting a new process (see below in comments):

use strict;
my $title = "Perl Version";
print "Content-type: text/html\n\n";
print "<html><head><title>$title</title></head><body>";
print "<h2>$title</h2>\n";
print "Perl version : ".$];
print "</body></html>"

source code – (download link)

The following code provides a little bit more information:

# Available under BSD License.
# See url
use strict;
my $command=`perl -v`;
my $title = "Perl Version";
print "Content-type: text/html\n\n";
print "<html><head><title>$title</title></head><body>";
print "<h1>$title</h1>\n";
print '<hr>';
print $command;
print '</hr>';
print "</body></html>";

Sample outputs:
[/caption] Upload script to your cgi-bin directory and execute the script by typing url suc as

The -V option

The -V option gives in depth information about Perl including platform, compiler options, patches applied by Linux or Unix distro, search path and much more. All you have to do is type the following simple command at a shell prompt:
perl -V
Sample outputs:

Summary of my perl5 (revision 5 version 28 subversion 1) configuration:
    uname='linux localhost 4.9.0 #1 smp debian 4.9.0 x86_64 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dcc=x86_64-linux-gnu-gcc -Dcpp=x86_64-linux-gnu-cpp -Dld=x86_64-linux-gnu-gcc -Dccflags=-DDEBIAN -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/perl-1_qjrE/perl-5.28.1=. -fstack-protector-strong -Wformat -Werror=format-security -Dldflags= -Wl,-Bsymbolic-functions -Wl,-z,relro -Dlddlflags=-shared -Wl,-Bsymbolic-functions -Wl,-z,relro -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.28 -Darchlib=/usr/lib/x86_64-linux-gnu/perl/5.28 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/x86_64-linux-gnu/perl5/5.28 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.28.1 -Dsitearch=/usr/local/lib/x86_64-linux-gnu/perl/5.28.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Duse64bitint -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -Ui_libutil -Ui_xlocale -Uversiononly -DDEBUGGING=-g -Doptimize=-O2 -dEs -Duseshrplib'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2 -g'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include'
    gccversion='9.2.1 20190909'
  Linker and Libraries:
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/9/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
  Dynamic Linking:
    lddlflags='-shared -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl): 
  Compile-time options:
  Locally applied patches:
    DEBPKG:debian/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
    DEBPKG:debian/db_file_ver - Remove overly restrictive DB_File version check.
    DEBPKG:debian/doc_info - Replace generic man(1) instructions with Debian-specific information.
    DEBPKG:debian/enc2xs_inc - Tweak enc2xs to follow symlinks and ignore missing @INC directories.
    DEBPKG:debian/errno_ver - Remove Errno version check due to upgrade problems with long-running processes.
    DEBPKG:debian/libperl_embed_doc - Note that libperl-dev package is required for embedded linking
    DEBPKG:fixes/respect_umask - Respect umask during installation
    DEBPKG:debian/writable_site_dirs - Set umask approproately for site install directories
    DEBPKG:debian/extutils_set_libperl_path - EU:MM: set location of libperl.a under /usr/lib
    DEBPKG:debian/no_packlist_perllocal - Don't install .packlist or perllocal.pod for perl or vendor
    DEBPKG:debian/fakeroot - Postpone LD_LIBRARY_PATH evaluation to the binary targets.
    DEBPKG:debian/instmodsh_doc - Debian policy doesn't install .packlist files for core or vendor.
    DEBPKG:debian/ld_run_path - Remove standard libs from LD_RUN_PATH as per Debian policy.
    DEBPKG:debian/libnet_config_path - Set location of libnet.cfg to /etc/perl/Net as /usr may not be writable.
    DEBPKG:debian/perlivp - Make perlivp skip include directories in /usr/local
    DEBPKG:debian/squelch-locale-warnings - Squelch locale warnings in Debian package maintainer scripts
    DEBPKG:debian/patchlevel - List packaged patches for 5.28.1-6build1 in patchlevel.h
    DEBPKG:fixes/document_makemaker_ccflags - [ #68613] Document that CCFLAGS should include $Config{ccflags}
    DEBPKG:debian/find_html2text - Configure CPAN::Distribution with correct name of html2text
    DEBPKG:debian/perl5db-x-terminal-emulator.patch - Invoke x-terminal-emulator rather than xterm in
    DEBPKG:debian/cpan-missing-site-dirs - Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
    DEBPKG:fixes/memoize_storable_nstore - [ #77790] Memoize::Storable: respect 'nstore' option not respected
    DEBPKG:debian/makemaker-pasthru - Pass LD settings through to subdirectories
    DEBPKG:debian/makemaker-manext - Make EU::MakeMaker honour MANnEXT settings in generated manpage headers
    DEBPKG:debian/kfreebsd-softupdates - Work around Debian Bug#796798
    DEBPKG:fixes/autodie-scope - Fix a scoping issue with "no autodie" and the "system" sub
    DEBPKG:fixes/memoize-pod - [ #89441] Fix POD errors in Memoize
    DEBPKG:debian/hurd-softupdates - Fix t/op/stat.t failures on hurd
    DEBPKG:fixes/math_complex_doc_great_circle - [ #114104] Math::Trig: clarify definition of great_circle_midpoint
    DEBPKG:fixes/math_complex_doc_see_also - [ #114105] Math::Trig: add missing SEE ALSO
    DEBPKG:fixes/math_complex_doc_angle_units - [ #114106] Math::Trig: document angle units
    DEBPKG:fixes/cpan_web_link - CPAN: Add link to main CPAN web site
    DEBPKG:debian/hppa_op_optimize_workaround - Temporarily lower the optimization of op.c on hppa due to gcc-6 problems
    DEBPKG:debian/installman-utf8 - Generate man pages with UTF-8 characters
    DEBPKG:fixes/getopt-long-4 - [ #122068] Fix issue #122068.
    DEBPKG:debian/hppa_opmini_optimize_workaround - Lower the optimization level of opmini.c on hppa
    DEBPKG:debian/sh4_op_optimize_workaround - Also lower the optimization level of op.c and opmini.c on sh4
    DEBPKG:debian/perldoc-pager - [ #120229] Fix perldoc terminal escapes when sensible-pager is less
    DEBPKG:debian/prune_libs - Prune the list of libraries wanted to what we actually need.
    DEBPKG:debian/mod_paths - Tweak @INC ordering for Debian
    DEBPKG:debian/configure-regen - Regenerate Configure et al. after probe unit changes
    DEBPKG:debian/deprecate-with-apt - Point users to Debian packages of deprecated core modules
    DEBPKG:debian/disable-stack-check - [perl #133327] Disable debugperl stack extension checks for binary compatibility with perl
    DEBPKG:debian/gdbm-fatal - [perl #133295] Temporarily skip GDBM_File fatal.t for gdbm >= 1.15 compatibility
    DEBPKG:fixes/storable-recursion - [perl #133326] [120060c] (perl #133326) fix and clarify handling of recurs_sv.
    DEBPKG:fixes/caretx-fallback - [perl #133573] [03b94aa] RT#133573: $^X fallback when platform-specific technique fails
    DEBPKG:fixes/eumm-usrmerge - Avoid mangling /bin non-perl shebangs on merged-/usr systems
    DEBPKG:fixes/errno-include-path - [6c5080f] [perl #133662] Make Errno_pm.PL compatible with /usr/include/<ARCH>/errno.h
    DEBPKG:fixes/kfreebsd-renameat - [a3c63a9] [perl #133668] Also work around renameat() kernel bug on GNU/kFreeBSD
    DEBPKG:fixes/time-local-2020 - [ #124787] Fix Time::Local tests
    DEBPKG:fixes/inplace-editing-bugfix/part1 - (perl #133659) move argvout cleanup to a new function
    DEBPKG:fixes/inplace-editing-bugfix/part2 - (perl #133659) tests for global destruction handling of inplace editing
    DEBPKG:fixes/inplace-editing-bugfix/part3 - (perl #133659) make an in-place edit successful if the exit status is zero
    DEBPKG:fixes/fix-manifest-failures - Fix t/porting/manifest.t failures when run in a foreign git checkout
    DEBPKG:fixes/pipe-open-bugfix/part1 - [perl #133726] Always mark pipe in pipe-open as inherit-on-exec
    DEBPKG:fixes/pipe-open-bugfix/part2 - [perl #133726] Always mark pipe in list pipe-open as inherit-on-exec
    DEBPKG:fixes/storable-probing/prereq1 - [3f4cad1] Storable: fix for strawberry build failures:
    DEBPKG:fixes/storable-probing/prereq2 - [perl #133411] [edf639f] (perl #133411) don't try to load Storable with -Dusecrosscompile
    DEBPKG:fixes/storable-probing/disable-probing - [perl #133708] [2a0bbd3] (perl #133708) remove build-time probing for stack limits for Storable
    DEBPKG:debian/perlbug-editor - Use "editor" as the default perlbug editor, as per Debian policy
    DEBPKG:fixes/posix-mbrlen - [25d7b7a] [perl #133928] Fix POSIX::mblen mbstate_t initialization on threaded perls with glibc
  Built under linux
  Compiled at Sep 11 2019 07:02:52

Perl varaibles

You can use $PERL_VERSION or $^V too as the revision, version, and subversion of the Perl interpreter, represented as a “version” object. This variable first appeared in perl version 5.6.0; earlier versions of perl will see an undefined value. Before perl v5.10.0 $^V was represented as a v-string. $^V can be used to determine whether the Perl interpreter executing a script is in the right range of versions. For example:

warn "Hashes not randomized!\n" if !$^V or $^V lt v5.8.1

To convert $^V into its string representation use “sprintf()”‘s “%vd” conversion:

printf "version is v%vd\n", $^V;  # Perl's version

For example one can use the following syntax:

## get Perl version demo ##
perl -e 'print "Perl version : $^V\n"'
perl -e 'print "Perl version : $PERL_VERSION\n"'

Check for Perl version and do something

# See if we got v5.10.1 would be "5.010001"
if ($] >= 5.010001)
    ## Do something as we got perl version 5.10.1 
     ## warn and die 


You learned finding about Perl version using various methods. See Perl site for more information here.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Dave Mar 17, 2008 @ 12:42

    It is overkill to run a whole new process to find out the version, just read about Perl’s builtin variables in PERLVAR

    In the code above change

    $command=`perl -v`;
    $command= $]

  • Tanguy Jan 2, 2010 @ 1:20

    Ou pour la version type v5.10.0 :
    $command = $^V;

  • Alister Apr 13, 2010 @ 23:54

    Or in versions of perl > v5.6 you can use the Version object variable $^V.

    $command = sprintf "v%vd", $^V ; # v5.8.9
  • Dodger Nov 9, 2015 @ 15:40

    Please do not tell people to write crappy Perl anymore. Seriously. People write enough crappy Perl as it is.

    I mean, what’s this “$command = $]” garbage? It’s *already a variable*. You don’t need to tell people to copy it into another (badly named) variable (badly name because it’s NOT a “command”). And what’s the “$title” variable for? What makes you think you’d need a variable for something that’s used only once? Or the multiple calls to print, one per line?

    It’s bad coding habits like this that get people started writing rubbish, inefficient Perl scripts which ultimately lead to pointy-haired managers thinking Perl is inefficient and inexplicably believing that Rails scales better or that Java is a streamlined solution. CUT. IT. OUT.

    And never ever ever ever ever, no matter how innocuous it looks, ever tell people to run a CGI script that doesn’t use strict. Seriously. FFS.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum