deprecate(3perl)
π deprecate β the Perl pragma manual page π
okay bestie, welcome to deprecate(3perl), the Perl Programmers Reference Guide page that is literally about telling people "hey this module is leaving the group chat soon" π«Ά
β¨ NAME β¨
deprecate β Perl pragma for deprecating the inclusion of a module in core
like, it's the little pragma that could, and it's lowkey the main character of dual-life module maintenance π
πΈ SYNOPSIS πΈ
use deprecate; # warn about future absence if loaded from core
that's it. that's the whole vibe. one line, no cap β¨
π¦ DESCRIPTION π¦
so here's the tea β β this pragma simplifies the maintenance of dual-life modules: modules that are gonna get yeeted out of the Perl core in some future Perl release, but are still living in core right now. still here. still iconic. but on notice π
the whole purpose of this pragma is to alert users to the status of such a module by issuing a warning that encourages them to install the module from CPAN, so that a future upgrade to a perl which omits the module will not break their code. protective behavior fr fr π‘οΈ
and here's the clever part, bestie β this warning will only be issued if the module was loaded from a core library directory. which means you can literally just leave the use deprecate line sitting in the CPAN version of the module too. because the pragma remains silent when the module is run from a non-core library directory, the pragma call does not need to be patched into or out of either the core or CPAN version of the module. the exact same code can be shipped for either purpose. one codebase, two vibes, zero patching π
π¨ Important Caveat π¨
okay this is the part where we need to be serious for a sec, ngl π
note that when a module installs from CPAN to a core library directory rather than the site library directories, the user gains no protection from having installed it. literally none. the shield does not deploy. π
at the same time, this pragma cannot detect when such a module has installed from CPAN to the core library, and so it would endlessly and uselessly exhort the user to upgrade. and likeβ¦ not the pragma yelling "UPGRADE!!!" into the void forever π
therefore modules that can install from CPAN to the core library must make sure not to call this pragma when they have done so. generally this means that the exact logic from the installer must be mirrored inside the module. E.g.:
# Makefile.PL
WriteMakefile(
# ...
INSTALLDIRS => ( "$]" >= 5.011 ? 'site' : 'perl' ),
);
# lib/Foo/Bar.pm
use if "$]" >= 5.011, 'deprecate';
(the above example shows the most important case of this: when the target is a Perl older than 5.12 β where the core library directories take precedence over the site library directories β and the module being installed was included in core in that Perl version. under those circumstances, an upgrade of the module from CPAN is only possible by installing to the core library.) so yeah, mirror your installer's logic inside the module. it's giving "copy your homework but change it slightly" except here you do copy it exactly πβ¨
π EXPORT π
None by default. The only method is "import", called by use deprecate;.
that's the whole export list. tiny. minimal. elegant. obsessed. π
π₯ SEE ALSO π₯
first example to "use deprecate;" was Switch.
π AUTHOR π
original version by Nicholas Clark π
π COPYRIGHT AND LICENSE π
Copyright (C) 2009, 2011
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
and that's the page babes π this was perl v5.44.0, dated 2026-10-17, and it's the deprecate(3perl) manpage β go forth, deprecate responsibly, and remember: warn only from core, or the vibe check fails πβ¨π¦
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms