CPAN::DISTROPREFS(3perl)
π CPAN::Distroprefs π
okay bestie, so this is CPAN::Distroprefs β she reads distroprefs files and matches them against stuff. that's literally her whole job and she does it flawlessly, no cap. π
β¨ SYNOPSIS β¨
use CPAN::Distroprefs;
my %info = (... distribution/environment info ...);
my $finder = CPAN::Distroprefs->find($prefs_dir, \%ext_map);
while (my $result = $finder->next) {
die $result->as_string if $result->is_fatal;
warn($result->as_string), next if $result->is_warning;
for my $pref (@{ $result->prefs }) {
if ($pref->matches(\%info)) {
return $pref;
}
}
}
like. look at that. gorgeous. π
πΈ DESCRIPTION πΈ
This module encapsulates reading Distroprefs and matching them against CPAN distributions. that's it, that's the vibe. she handles the reading, she handles the matching, you just sit there looking pretty. π
π¦ INTERFACE π¦
my $finder = CPAN::Distroprefs->find($dir, \%ext_map);
while (my $result = $finder->next) { ... }
Build an iterator which finds distroprefs files in the tree below the given directory. π§ and listen β within the tree, directories matching m/^[._]/ are pruned. gone. not invited. bye bestie. π
%ext_map is a hashref whose keys are file extensions and whose values are modules used to load matching files:
{
'yml' => 'YAML::Syck',
'dd' => 'Data::Dumper',
...
}
Every single time $finder->next gets called, the iterator returns one of two possible values:
- a
CPAN::Distroprefs::Resultobject, or undef, indicating that no prefs files remain to be found π
β RESULTS β
find() returns CPAN::Distroprefs::Result objects to indicate success or failure when reading a prefs file. she's giving transparency, she's giving receipts. π
π Common
All results share some common attributes:
typeβ literally one of"success","warning", or"fatal". that's the whole mood board.fileβ the file from which these prefs were read, or to which this error refers (relative filename, okay)extβ the file's extension, which determines how to load itdirβ the directory the file was read fromabsβ the absolute path to the file, no shortcuts
π Errors
Error results (warning and fatal) contain:
msgβ the error message, usually either$!or a YAML error. yeah. YAML errors are a thing and yes they're dramatic. π
π₯ Successes
Success results contain:
prefsβ an arrayref ofCPAN::Distroprefs::Prefobjects β¨
π PREFS π
CPAN::Distroprefs::Pref objects represent individual distroprefs documents. They are constructed automatically as part of "success" results from find(). so you don't even have to lift a finger, she does it for you. queen behavior. π
dataβ the pref information as a hashref, suitable for e.g. passing to Kwalifymatch_attributesβ returns a list of the valid match attributes (see the Distroprefs section in CPAN). currently:env perl perlconfig distribution modulehas_any_matchβ true if this pref has a'match'attribute at allhas_valid_subkeysβ true if this pref has a'match'attribute and at least one valid match attributematchesβ the moment we've all been waiting for:
if ($pref->matches(\%arg)) { ... }
true if this pref matches the passed-in hashref, which must have a value for each of the match_attributes (above). no missing values, bestie, she will notice. β
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, share the love, it's literally the rules. π«Ά
and that's the whole page, bestie!! mwah π this was perl v5.44.0, dated 2026-10-17 β iconic documentation, no notes, periodt. ππβ¨
π¦ 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