CPAN::Meta::Merge(3pm)
π NAME π
Okay bestie, welcome to the Perl Programmers Reference Guide page for CPAN::Meta::Merge(3pm) β the module thatβs literally all about merging CPAN Meta fragments. β¨
πΈ VERSION πΈ
version 2.150010 β noted, saved, slayed. π
π¦ SYNOPSIS π¦
my $merger = CPAN::Meta::Merge->new(default_version => "2");
my $meta = $merger->merge($base, @additional);
π DESCRIPTION π
The methods are the main character here, so letβs get into them. π«Ά
π METHODS π
β¨ new β¨
This creates a CPAN::Meta::Merge object. It takes one mandatory named argument, "version", declaring the version of the meta-spec that must be used for the merge. It can optionally take an extra_mappings argument that allows one to add additional merging functions for specific elements. π
The extra_mappings arguments take a hash ref with the same type of structure as described in CPAN::Meta::Spec, except with its values as one of the defined merge strategies or a code ref to a merging function. π§
my $merger = CPAN::Meta::Merge->new(
default_version => '2',
extra_mappings => {
'optional_features' => \&custom_merge_function,
'x_custom' => 'set_addition',
'x_meta_meta' => {
name => 'identical',
tags => 'set_addition',
}
}
);
π merge(@fragments) π
Merge all @fragments together. It will accept both CPAN::Meta objects and (possibly incomplete) hashrefs of metadata. No cap, itβs flexible like that. π
π₯ MERGE STRATEGIES π₯
"merge" uses various strategies to combine different elements of the CPAN::Meta objects. The following strategies can be used with the extra_mappings argument of "new": π
β identical β
The elements must be identical. Thatβs it, thatβs the vibe check. π
π set_addition π
The union of two array refs. π¦
[ a, b ] U [ a, c] = [ a, b, c ]
π« uniq_map π«
Key value pairs from the right hash are merged to the left hash. Key collisions are only allowed if their values are the same. This merge function will recurse into nested hash refs following the same merge rules. π«Ά
π improvise π
This merge strategy will try to pick the appropriate predefined strategy based on what element type. Array refs will try to use the "set_addition" strategy, Hash refs will try to use the "uniq_map" strategy, and everything else will try the "identical" strategy. Itβs giving adaptive icon behavior. π
π AUTHORS π
David Golden <dagolden@cpan.org>Ricardo Signes <rjbs@cpan.org>Adam Kennedy <adamk@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors. πΈ
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. β¨
And thatβs the whole page, bestie: brought to you by perl v5.42.3, dated 2026-11-03, and itβs the CPAN::Meta::Merge(3pm) manual. Byeee! π
ππ
π¦ 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