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::Result object, 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 it
  • dir β€” the directory the file was read from
  • abs β€” 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 of CPAN::Distroprefs::Pref objects ✨

πŸŽ€ 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 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 β€” 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