Security Advisories (19)
The XSLoader::load method in XSLoader in Perl does not properly locate .so files when called in a string eval, which might allow local users to execute arbitrary code via a Trojan horse library under the current working directory.
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/5RFDMASVZLFZYBB2GNTZXU6I76E4NA4V/
- https://github.com/Perl/perl5/commit/08e3451d7b3b714ad63a27f1b9c2a23ee75d15ee
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PRIPTDA6XINBVEJXI2NGLKVEINBREHTN/
- http://www.openwall.com/lists/oss-security/2016/07/07/1
- http://www.openwall.com/lists/oss-security/2016/07/08/5
- https://rt.cpan.org/Public/Bug/Display.html?id=115808
- http://www.debian.org/security/2016/dsa-3628
- http://www.securitytracker.com/id/1036260
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ITYZJXQH24X2F2LAOQEQAC5KXLYJTJ76/
- http://www.oracle.com/technetwork/topics/security/bulletinjul2016-3090568.html
- http://www.securityfocus.com/bid/91685
- https://security.gentoo.org/glsa/201701-75
- https://usn.ubuntu.com/3625-2/
- https://usn.ubuntu.com/3625-1/
- https://github.com/Perl/perl5/blob/blead/pod/perl5260delta.pod
regcomp.c in Perl before 5.30.3 allows a buffer overflow via a crafted regular expression because of recursive S_study_chunk calls.
- https://github.com/Perl/perl5/compare/v5.30.2...v5.30.3
- https://github.com/Perl/perl5/blob/blead/pod/perl5303delta.pod
- https://github.com/Perl/perl5/issues/16947
- https://github.com/perl/perl5/commit/66bbb51b93253a3f87d11c2695cfb7bdb782184a
- https://github.com/Perl/perl5/issues/17743
- https://security.netapp.com/advisory/ntap-20200611-0001/
- https://security.gentoo.org/glsa/202006-03
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IN3TTBO5KSGWE5IRIKDJ5JSQRH7ANNXE/
- http://lists.opensuse.org/opensuse-security-announce/2020-06/msg00044.html
- https://www.oracle.com/security-alerts/cpuoct2020.html
- https://www.oracle.com/security-alerts/cpujan2021.html
- https://www.oracle.com/security-alerts/cpuApr2021.html
- https://www.oracle.com//security-alerts/cpujul2021.html
- https://www.oracle.com/security-alerts/cpuoct2021.html
- https://www.oracle.com/security-alerts/cpujan2022.html
- https://www.oracle.com/security-alerts/cpuapr2022.html
- https://perldoc.perl.org/perl5283delta
- https://perldoc.perl.org/perl5303delta
- https://perldoc.perl.org/perl5320delta
Perl before 5.30.3 has an integer overflow related to mishandling of a "PL_regkind[OP(n)] == NOTHING" situation. A crafted regular expression could lead to malformed bytecode with a possibility of instruction injection.
- https://github.com/Perl/perl5/compare/v5.30.2...v5.30.3
- https://github.com/perl/perl5/commit/3295b48defa0f8570114877b063fe546dd348b3c
- https://github.com/perl/perl5/commit/0a320d753fe7fca03df259a4dfd8e641e51edaa8
- https://github.com/Perl/perl5/blob/blead/pod/perl5303delta.pod
- https://security.netapp.com/advisory/ntap-20200611-0001/
- https://security.gentoo.org/glsa/202006-03
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IN3TTBO5KSGWE5IRIKDJ5JSQRH7ANNXE/
- http://lists.opensuse.org/opensuse-security-announce/2020-06/msg00044.html
- https://www.oracle.com/security-alerts/cpuoct2020.html
- https://www.oracle.com/security-alerts/cpujan2021.html
- https://www.oracle.com/security-alerts/cpuApr2021.html
- https://www.oracle.com//security-alerts/cpujul2021.html
- https://www.oracle.com/security-alerts/cpuoct2021.html
- https://www.oracle.com/security-alerts/cpujan2022.html
- https://www.oracle.com/security-alerts/cpuapr2022.html
- https://perldoc.perl.org/perl5283delta
- https://perldoc.perl.org/perl5303delta
- https://perldoc.perl.org/perl5320delta
Perl before 5.30.3 on 32-bit platforms allows a heap-based buffer overflow because nested regular expression quantifiers have an integer overflow.
- https://github.com/Perl/perl5/compare/v5.30.2...v5.30.3
- https://github.com/perl/perl5/commit/897d1f7fd515b828e4b198d8b8bef76c6faf03ed
- https://github.com/Perl/perl5/blob/blead/pod/perl5303delta.pod
- https://security.netapp.com/advisory/ntap-20200611-0001/
- https://security.gentoo.org/glsa/202006-03
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IN3TTBO5KSGWE5IRIKDJ5JSQRH7ANNXE/
- http://lists.opensuse.org/opensuse-security-announce/2020-06/msg00044.html
- https://www.oracle.com/security-alerts/cpuoct2020.html
- https://www.oracle.com/security-alerts/cpujan2021.html
- https://www.oracle.com/security-alerts/cpuApr2021.html
- https://www.oracle.com//security-alerts/cpujul2021.html
- https://www.oracle.com/security-alerts/cpuoct2021.html
- https://www.oracle.com/security-alerts/cpujan2022.html
- https://www.oracle.com/security-alerts/cpuapr2022.html
- https://perldoc.perl.org/perl5283delta
- https://perldoc.perl.org/perl5303delta
- https://perldoc.perl.org/perl5320delta
An issue was discovered in Perl 5.22 through 5.26. Matching a crafted locale dependent regular expression can cause a heap-based buffer over-read and potentially information disclosure.
- https://www.debian.org/security/2018/dsa-4172
- https://rt.perl.org/Public/Bug/Display.html?id=132063
- http://www.securitytracker.com/id/1040681
- https://access.redhat.com/errata/RHSA-2018:1192
- https://usn.ubuntu.com/3625-1/
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://perldoc.perl.org/perl5244delta
- https://perldoc.perl.org/perl5262delta
- https://github.com/Perl/perl5/issues/16143
An issue was discovered in Perl 5.18 through 5.26. A crafted regular expression can cause a heap-based buffer overflow, with control over the bytes written.
- https://www.debian.org/security/2018/dsa-4172
- https://rt.perl.org/Public/Bug/Display.html?id=132227
- http://www.securitytracker.com/id/1040681
- https://access.redhat.com/errata/RHSA-2018:1192
- https://usn.ubuntu.com/3625-1/
- http://www.securitytracker.com/id/1042004
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://perldoc.perl.org/perl5244delta
- https://perldoc.perl.org/perl5262delta
Heap-based buffer overflow in the pack function in Perl before 5.26.2 allows context-dependent attackers to execute arbitrary code via a large item count.
- https://www.debian.org/security/2018/dsa-4172
- https://rt.perl.org/Public/Bug/Display.html?id=131844
- https://lists.debian.org/debian-lts-announce/2018/04/msg00009.html
- http://www.securitytracker.com/id/1040681
- https://usn.ubuntu.com/3625-2/
- https://usn.ubuntu.com/3625-1/
- http://www.securityfocus.com/bid/103953
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://perldoc.perl.org/perl5244delta
- https://perldoc.perl.org/perl5262delta
- https://github.com/Perl/perl5/issues/16098
Perl before 5.26.3 has a buffer overflow via a crafted regular expression that triggers invalid write operations.
- https://www.debian.org/security/2018/dsa-4347
- https://rt.perl.org/Ticket/Display.html?id=131649
- https://metacpan.org/changes/release/SHAY/perl-5.26.3
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RWQGEB543QN7SSBRKYJM6PSOC3RLYGSM/
- https://github.com/Perl/perl5/commit/19a498a461d7c81ae3507c450953d1148efecf4f
- https://bugzilla.redhat.com/show_bug.cgi?id=1646751
- http://www.securitytracker.com/id/1042181
- https://usn.ubuntu.com/3834-1/
- http://www.securityfocus.com/bid/106145
- https://access.redhat.com/errata/RHSA-2019:0010
- https://access.redhat.com/errata/RHSA-2019:0001
- https://security.netapp.com/advisory/ntap-20190221-0003/
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
Perl before 5.26.3 has a buffer over-read via a crafted regular expression that triggers disclosure of sensitive information from process memory.
- https://www.debian.org/security/2018/dsa-4347
- https://usn.ubuntu.com/3834-2/
- https://rt.perl.org/Ticket/Display.html?id=133192
- https://metacpan.org/changes/release/SHAY/perl-5.26.3
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RWQGEB543QN7SSBRKYJM6PSOC3RLYGSM/
- https://github.com/Perl/perl5/commit/43b2f4ef399e2fd7240b4eeb0658686ad95f8e62
- https://bugzilla.redhat.com/show_bug.cgi?id=1646738
- http://www.securitytracker.com/id/1042181
- https://usn.ubuntu.com/3834-1/
- https://access.redhat.com/errata/RHSA-2019:0010
- https://access.redhat.com/errata/RHSA-2019:0001
- https://security.netapp.com/advisory/ntap-20190221-0003/
- https://support.apple.com/kb/HT209600
- https://seclists.org/bugtraq/2019/Mar/42
- http://seclists.org/fulldisclosure/2019/Mar/49
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
Perl before 5.26.3 and 5.28.0 before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.
- https://www.debian.org/security/2018/dsa-4347
- https://rt.perl.org/Public/Bug/Display.html?id=133423
- https://metacpan.org/changes/release/SHAY/perl-5.28.1
- https://metacpan.org/changes/release/SHAY/perl-5.26.3
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RWQGEB543QN7SSBRKYJM6PSOC3RLYGSM/
- https://bugzilla.redhat.com/show_bug.cgi?id=1646734
- http://www.securitytracker.com/id/1042181
- https://usn.ubuntu.com/3834-1/
- http://www.securityfocus.com/bid/106179
- https://access.redhat.com/errata/RHSA-2019:0010
- https://access.redhat.com/errata/RHSA-2019:0001
- https://security.netapp.com/advisory/ntap-20190221-0003/
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://perldoc.perl.org/perl5281delta
- https://perldoc.perl.org/perl5263delta
Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.
- https://www.debian.org/security/2018/dsa-4347
- https://usn.ubuntu.com/3834-2/
- https://rt.perl.org/Ticket/Display.html?id=133204
- https://metacpan.org/changes/release/SHAY/perl-5.28.1
- https://metacpan.org/changes/release/SHAY/perl-5.26.3
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RWQGEB543QN7SSBRKYJM6PSOC3RLYGSM/
- https://lists.debian.org/debian-lts-announce/2018/11/msg00039.html
- https://github.com/Perl/perl5/commit/34716e2a6ee2af96078d62b065b7785c001194be
- https://bugzilla.redhat.com/show_bug.cgi?id=1646730
- http://www.securitytracker.com/id/1042181
- https://usn.ubuntu.com/3834-1/
- http://www.securityfocus.com/bid/106145
- https://access.redhat.com/errata/RHSA-2019:0010
- https://access.redhat.com/errata/RHSA-2019:0001
- https://access.redhat.com/errata/RHSA-2019:0109
- https://security.netapp.com/advisory/ntap-20190221-0003/
- https://support.apple.com/kb/HT209600
- https://seclists.org/bugtraq/2019/Mar/42
- http://seclists.org/fulldisclosure/2019/Mar/49
- https://kc.mcafee.com/corporate/index?page=content&id=SB10278
- https://access.redhat.com/errata/RHBA-2019:0327
- https://access.redhat.com/errata/RHSA-2019:1790
- https://www.oracle.com/technetwork/security-advisory/cpujul2019-5072835.html
- https://access.redhat.com/errata/RHSA-2019:1942
- https://access.redhat.com/errata/RHSA-2019:2400
- https://security.gentoo.org/glsa/201909-01
- https://www.oracle.com/security-alerts/cpuapr2020.html
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://perldoc.perl.org/perl5281delta
- https://perldoc.perl.org/perl5263delta
Buffer overflow in the S_grok_bslash_N function in regcomp.c in Perl 5 before 5.24.3-RC1 and 5.26.x before 5.26.1-RC1 allows remote attackers to disclose sensitive information or cause a denial of service (application crash) via a crafted regular expression with an invalid '\\N{U+...}' escape.
- https://perl5.git.perl.org/perl.git/log/refs/tags/v5.26.1-RC1
- https://perl5.git.perl.org/perl.git/log/refs/tags/v5.24.3-RC1
- https://perl5.git.perl.org/perl.git/commitdiff/2be4edede4ae226e2eebd4eff28cedd2041f300f#patch1
- https://bugzilla.redhat.com/show_bug.cgi?id=1492093
- http://www.securityfocus.com/bid/100852
- http://mirror.cucumberlinux.com/cucumber/cucumber-1.0/source/lang-base/perl/patches/CVE-2017-12883.patch
- https://rt.perl.org/Public/Bug/Display.html?id=131598
- http://www.debian.org/security/2017/dsa-3982
- https://security.netapp.com/advisory/ntap-20180426-0001/
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://github.com/Perl/perl5/issues/16025
- https://perldoc.perl.org/perl5243delta
- https://perldoc.perl.org/perl5280delta
- https://perldoc.perl.org/perl5261delta
Heap-based buffer overflow in the S_regatom function in regcomp.c in Perl 5 before 5.24.3-RC1 and 5.26.x before 5.26.1-RC1 allows remote attackers to cause a denial of service (out-of-bounds write) via a regular expression with a '\\N{}' escape and the case-insensitive modifier.
- https://perl5.git.perl.org/perl.git/log/refs/tags/v5.26.1-RC1
- https://perl5.git.perl.org/perl.git/log/refs/tags/v5.24.3-RC1
- https://perl5.git.perl.org/perl.git/commitdiff/96c83ed78aeea1a0496dd2b2d935869a822dc8a5
- https://bugzilla.redhat.com/show_bug.cgi?id=1492091
- http://www.securityfocus.com/bid/100860
- https://rt.perl.org/Public/Bug/Display.html?id=131582
- http://www.debian.org/security/2017/dsa-3982
- https://security.netapp.com/advisory/ntap-20180426-0001/
- https://www.oracle.com/security-alerts/cpujul2020.html
- https://github.com/Perl/perl5/issues/16021
- https://perldoc.perl.org/perl5243delta
- https://perldoc.perl.org/perl5261delta
- https://perldoc.perl.org/perl5280delta
The (1) S_reghop3, (2) S_reghop4, and (3) S_reghopmaybe3 functions in regexec.c in Perl before 5.24.0 allow context-dependent attackers to cause a denial of service (infinite loop) via crafted utf-8 data, as demonstrated by "a\x80."
- http://lists.fedoraproject.org/pipermail/package-announce/2016-May/183592.html
- http://www.openwall.com/lists/oss-security/2016/04/20/7
- https://bugzilla.redhat.com/show_bug.cgi?id=1329106
- https://rt.perl.org/Public/Bug/Display.html?id=123562
- http://www.openwall.com/lists/oss-security/2016/04/20/5
- http://perl5.git.perl.org/perl.git/commitdiff/22b433eff9a1ffa2454e18405a56650f07b385b5
- https://h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c05240731
- http://www.oracle.com/technetwork/topics/security/bulletinjul2016-3090568.html
- http://www.oracle.com/technetwork/topics/security/bulletinapr2016-2952098.html
- http://www.securityfocus.com/bid/86707
- https://security.gentoo.org/glsa/201701-75
- https://usn.ubuntu.com/3625-2/
- https://usn.ubuntu.com/3625-1/
Perl for Windows relies on the system path environment variable to find the shell (cmd.exe). When running an executable which uses Windows Perl interpreter, Perl attempts to find and execute cmd.exe within the operating system. However, due to path search order issues, Perl initially looks for cmd.exe in the current working directory. An attacker with limited privileges can exploit this behavior by placing cmd.exe in locations with weak permissions, such as C:\ProgramData. By doing so, when an administrator attempts to use this executable from these compromised locations, arbitrary code can be executed.
In Perl before 5.38.2, S_parse_uniprop_string in regcomp.c can write to unallocated space because a property name associated with a \p{...} regular expression construct is mishandled. The earliest affected version is 5.30.0.
A heap buffer overflow vulnerability was discovered in Perl. When there are non-ASCII bytes in the left-hand-side of the `tr` operator, `S_do_trans_invmap` can overflow the destination pointer `d`. $ perl -e '$_ = "\x{FF}" x 1000000; tr/\xFF/\x{100}/;' Segmentation fault (core dumped) It is believed that this vulnerability can enable Denial of Service and possibly Code Execution attacks on platforms that lack sufficient defenses.
- https://github.com/Perl/perl5/commit/87f42aa0e0096e9a346c9672aa3a0bd3bef8c1dd.patch
- https://metacpan.org/release/SHAY/perl-5.38.4/changes
- https://metacpan.org/release/SHAY/perl-5.40.2/changes
- http://www.openwall.com/lists/oss-security/2025/04/13/3
- http://www.openwall.com/lists/oss-security/2025/04/13/4
Perl threads have a working directory race condition where file operations may target unintended paths. If a directory handle is open at thread creation, the process-wide current working directory is temporarily changed in order to clone that handle for the new thread, which is visible from any third (or more) thread already running. This may lead to unintended operations such as loading code or accessing files from unexpected locations, which a local attacker may be able to exploit. The bug was introduced in commit 11a11ecf4bea72b17d250cfb43c897be1341861e and released in Perl version 5.13.6
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098226
- https://github.com/Perl/perl5/commit/11a11ecf4bea72b17d250cfb43c897be1341861e
- https://github.com/Perl/perl5/commit/918bfff86ca8d6d4e4ec5b30994451e0bd74aba9.patch
- https://github.com/Perl/perl5/issues/10387
- https://github.com/Perl/perl5/issues/23010
- https://perldoc.perl.org/5.14.0/perl5136delta#Directory-handles-not-copied-to-threads
- https://www.openwall.com/lists/oss-security/2025/05/22/2
- http://www.openwall.com/lists/oss-security/2025/05/23/1
- http://www.openwall.com/lists/oss-security/2025/05/30/4
(1) cpan/Archive-Tar/bin/ptar, (2) cpan/Archive-Tar/bin/ptardiff, (3) cpan/Archive-Tar/bin/ptargrep, (4) cpan/CPAN/scripts/cpan, (5) cpan/Digest-SHA/shasum, (6) cpan/Encode/bin/enc2xs, (7) cpan/Encode/bin/encguess, (8) cpan/Encode/bin/piconv, (9) cpan/Encode/bin/ucmlint, (10) cpan/Encode/bin/unidump, (11) cpan/ExtUtils-MakeMaker/bin/instmodsh, (12) cpan/IO-Compress/bin/zipdetails, (13) cpan/JSON-PP/bin/json_pp, (14) cpan/Test-Harness/bin/prove, (15) dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp, (16) dist/Module-CoreList/corelist, (17) ext/Pod-Html/bin/pod2html, (18) utils/c2ph.PL, (19) utils/h2ph.PL, (20) utils/h2xs.PL, (21) utils/libnetcfg.PL, (22) utils/perlbug.PL, (23) utils/perldoc.PL, (24) utils/perlivp.PL, and (25) utils/splain.PL in Perl 5.x before 5.22.3-RC2 and 5.24 before 5.24.1-RC2 do not properly remove . (period) characters from the end of the includes directory array, which might allow local users to gain privileges via a Trojan horse module under the current working directory.
- https://perldoc.perl.org/5.24.1/perldelta
- http://lists.opensuse.org/opensuse-security-announce/2019-08/msg00002.html
- http://perl5.git.perl.org/perl.git/commit/cee96d52c39b1e7b36e1c62d38bcd8d86e9a41ab
- http://www.debian.org/security/2016/dsa-3628
- http://www.nntp.perl.org/group/perl.perl5.porters/2016/07/msg238271.html
- http://www.securityfocus.com/bid/92136
- http://www.securitytracker.com/id/1036440
- https://h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c05240731
- https://lists.apache.org/thread.html/7f6a16bc0fd0fd5e67c7fd95bd655069a2ac7d1f88e42d3c853e601c%40%3Cannounce.apache.org%3E
- https://lists.debian.org/debian-lts-announce/2018/11/msg00016.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2FBQOCV3GBAN2EYZUM3CFDJ4ECA3GZOK/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/DOFRQWJRP2NQJEYEWOMECVW3HAMD5SYN/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TZBNQH3DMI7HDELJAZ4TFJJANHXOEDWH/
- https://rt.perl.org/Public/Bug/Display.html?id=127834
- https://security.gentoo.org/glsa/201701-75
- https://security.gentoo.org/glsa/201812-07
- http://lists.opensuse.org/opensuse-security-announce/2019-08/msg00002.html
- http://perl5.git.perl.org/perl.git/commit/cee96d52c39b1e7b36e1c62d38bcd8d86e9a41ab
- http://www.debian.org/security/2016/dsa-3628
- http://www.nntp.perl.org/group/perl.perl5.porters/2016/07/msg238271.html
- http://www.securityfocus.com/bid/92136
- http://www.securitytracker.com/id/1036440
- https://h20566.www2.hpe.com/portal/site/hpsc/public/kb/docDisplay?docId=emr_na-c05240731
- https://lists.apache.org/thread.html/7f6a16bc0fd0fd5e67c7fd95bd655069a2ac7d1f88e42d3c853e601c%40%3Cannounce.apache.org%3E
- https://lists.debian.org/debian-lts-announce/2018/11/msg00016.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2FBQOCV3GBAN2EYZUM3CFDJ4ECA3GZOK/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/DOFRQWJRP2NQJEYEWOMECVW3HAMD5SYN/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TZBNQH3DMI7HDELJAZ4TFJJANHXOEDWH/
- https://rt.perl.org/Public/Bug/Display.html?id=127834
- https://security.gentoo.org/glsa/201701-75
- https://security.gentoo.org/glsa/201812-07
NAME
integer - Perl pragma to use integer arithmetic instead of floating point
SYNOPSIS
use integer;
$x = 10/3;
# $x is now 3, not 3.33333333333333333
DESCRIPTION
This tells the compiler to use integer operations from here to the end of the enclosing BLOCK. On many machines, this doesn't matter a great deal for most computations, but on those without floating point hardware, it can make a big difference in performance.
Note that this only affects how most of the arithmetic and relational operators handle their operands and results, and not how all numbers everywhere are treated. Specifically, use integer; has the effect that before computing the results of the arithmetic operators (+, -, *, /, %, +=, -=, *=, /=, %=, and unary minus), the comparison operators (<, <=, >, >=, ==, !=, <=>), and the bitwise operators (|, &, ^, <<, >>, |=, &=, ^=, <<=, >>=), the operands have their fractional portions truncated (or floored), and the result will have its fractional portion truncated as well. In addition, the range of operands and results is restricted to that of familiar two's complement integers, i.e., -(2**31) .. (2**31-1) on 32-bit architectures, and -(2**63) .. (2**63-1) on 64-bit architectures. For example, this code
use integer;
$x = 5.8;
$y = 2.5;
$z = 2.7;
$a = 2**31 - 1; # Largest positive integer on 32-bit machines
$, = ", ";
print $x, -$x, $x+$y, $x-$y, $x/$y, $x*$y, $y==$z, $a, $a+1;
will print: 5.8, -5, 7, 3, 2, 10, 1, 2147483647, -2147483648
Note that $x is still printed as having its true non-integer value of 5.8 since it wasn't operated on. And note too the wrap-around from the largest positive integer to the largest negative one. Also, arguments passed to functions and the values returned by them are not affected by use integer;. E.g.,
srand(1.5);
$, = ", ";
print sin(.5), cos(.5), atan2(1,2), sqrt(2), rand(10);
will give the same result with or without use integer; The power operator ** is also not affected, so that 2 ** .5 is always the square root of 2. Now, it so happens that the pre- and post- increment and decrement operators, ++ and --, are not affected by use integer; either. Some may rightly consider this to be a bug -- but at least it's a long-standing one.
Finally, use integer; also has an additional affect on the bitwise operators. Normally, the operands and results are treated as unsigned integers, but with use integer; the operands and results are signed. This means, among other things, that ~0 is -1, and -2 & -5 is -6.
Internally, native integer arithmetic (as provided by your C compiler) is used. This means that Perl's own semantics for arithmetic operations may not be preserved. One common source of trouble is the modulus of negative numbers, which Perl does one way, but your hardware may do another.
% perl -le 'print (4 % -3)'
-2
% perl -Minteger -le 'print (4 % -3)'
1
See "Pragmatic Modules" in perlmodlib, "Integer Arithmetic" in perlop
Module Install Instructions
To install vars, copy and paste the appropriate command in to your terminal.
cpanm vars
perl -MCPAN -e shell
install vars
For more information on module installation, please visit the detailed CPAN module installation guide.