NAME

PersonName::Format::Pattern - Parsed CLDR person-name pattern

SYNOPSIS

my $pattern = PersonName::Format::Pattern->new(
    '{title} {given} {given2} {surname}, {credentials}'
);

my $result = $pattern->format( $name );

DESCRIPTION

This class parses and validates one CLDR namePattern. It retains a structured sequence of literal and field tokens, counts populated and empty fields, chooses the best pattern from a group, and renders missing fields structurally.

Unresolved field modifiers are delegated to a modifier_resolver callback. Modifiers consumed by the name object are not passed to that callback.

METHODS

format

$pattern->format(
    $name,
    modifier_resolver => sub
    {
        my( $modifier, $value, $field, $token, $name ) = @_;
        ...
        return( $value );
    },
);

num_empty_fields

Returns the number of field tokens whose resolved value is undefined or empty.

num_populated_fields

Returns the number of field tokens whose resolved value is defined and nonempty.

pattern

Returns the original pattern text.

select_best

Selects the pattern with the greatest number of populated fields, then the fewest empty fields, then the alphabetically least pattern text.

tokens

Returns a detached copy of the parsed token sequence.

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT & LICENSE

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.