CPAN::Distroprefs(3pm)
πΈ NAME πΈ
okay so bestie, this is CPAN::Distroprefs(3pm) β CPAN::Distroprefs β from the Perl Programmers Reference Guide, and its whole thing is: read and match distroprefs. That's the tagline, that's the assignment, that's the vibe. π
β¨ 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;
}
}
}
π DESCRIPTION π
This module encapsulates reading Distroprefs and matching them against CPAN distributions. No cap, that's literally the whole job. π«Ά
π«Ά 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. Within the tree, directories matching m/^[._]/ are pruned β yeah, they get skipped, respectfully. π§
%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',
...
}
Each time $finder->next is called, the iterator returns one of two possible values:
- a
CPAN::Distroprefs::Resultobject 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. Iconic behavior, honestly. π
π§Έ Common π§Έ
All results share some common attributes:
typeβ"success","warning", or"fatal"β the result's whole mood.fileβ the file from which these prefs were read, or to which this error refers (relative filename).extβ the file's extension, which determines how to load it.dirβ the directory the file was read from.absβ the absolute path to the file.
π Errors π
Error results (warning and fatal) contain:
msgβ the error message (usually either$!or a YAML error). π
π Successes π
Success results contain:
prefsβ an arrayref ofCPAN::Distroprefs::Prefobjects. slay. β¨
π PREFS π
CPAN::Distroprefs::Pref objects represent individual distroprefs documents. They are constructed automatically as part of "success" results from find(). main character energy fr fr. π
dataβ the pref information as a hashref, suitable for e.g. passing to Kwalify.match_attributesβ returns a list of the valid match attributes (see the Distroprefs section in CPAN). currently:"env perl perlconfig distribution module".has_any_matchβ true if this pref has a'match'attribute at all.has_valid_subkeysβ true if this pref has a'match'attribute and at least one valid match attribute.matchesβ
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). iykyk. π¦
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
mwah π β this page is from perl v5.42.3, dated 2026-11-03, and it's the CPAN::Distroprefs(3pm) manual. byeee bestie π«Ά
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms