NAME
Test::CPAN::Health::Check::Deprecations - Detect use of deprecated Perl features
SYNOPSIS
use Test::CPAN::Health::Check::Deprecations;
my $check = Test::CPAN::Health::Check::Deprecations->new;
my $result = $check->run($dist);
printf "%s: %s\n", $result->status, $result->summary;
DESCRIPTION
Scans all source files for a curated set of deprecated or removed Perl features and modules, using regular-expression matching (no external CPAN module required):
given/whenblocks (removed from default feature set in Perl 5.36).$[array-base variable (deprecated since Perl 5.12).UNIVERSAL::isa()andUNIVERSAL::can()called as functions (deprecated since Perl 5.26).use UNIVERSAL(deprecated since Perl 5.22).use Switch(removed from core since Perl 5.10).
Score = round((clean_files / total_files) * 100). Files with any hit count as "affected". Status thresholds: pass ≥ 90 %, warn ≥ 50 %, fail below 50 %.
LIMITATIONS
Pattern matching does not parse Perl; occurrences inside strings, heredocs, or comments will produce false positives. The check deliberately errs on the side of over-reporting to prompt manual review.
The list of deprecated features is curated manually and may be incomplete.
run
PURPOSE
Search every source file for known-deprecated constructs and return a proportional score.
API SPECIFICATION
INPUT
dist Test::CPAN::Health::Distribution required
context Hashref optional
OUTPUT
Test::CPAN::Health::Result with check_id 'deprecations'.
MESSAGES
Code | Severity | Message | Resolution
------+----------+-----------------------------------------------+-----------
DP001 | SKIP | No source files found | Add source files
DP002 | PASS | No deprecated constructs found |
DP003 | WARN | Deprecated constructs found in N file(s) | Remove usage
DP004 | FAIL | Most files use deprecated constructs | Remove usage
FORMAL SPECIFICATION
-- Z schema (placeholder) --
DeprecationsOp
clean_files : N
total_files : N
score : 0..100
-------------------------------------------------------
total_files = 0 => status = skip
score >= 90 => status = pass
score >= 50 => status = warn
score < 50 => status = fail
SIDE EFFECTS
Reads source files only; no network or subprocess I/O.
USAGE EXAMPLE
my $result = Test::CPAN::Health::Check::Deprecations->new->run($dist);
print $result->summary;
AUTHOR
Nigel Horne, <njh at nigelhorne.com>
LICENSE AND COPYRIGHT
Copyright (C) 2025-2026 Nigel Horne.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.