NAME

Lingua::famibeib::Prefix - module to interact with famibeib word prefixes

VERSION

version v0.07

SYNOPSIS

use Lingua::famibeib::Prefix;

(since v0.06)

This package is used to store famibeib word prefixes and query them about their properties.

This module inherits from Data::Identifier::Interface::Simple, and Data::Identifier::Interface::Subobjects. Instances are overloaded so they will stringify to their string representation as per "as_string".

METHODS

new

my Lingua::famibeib::Prefix $prefix = Lingua::famibeib::Prefix->new($type => $value);
# e.g:
my Lingua::famibeib::Prefix $prefix = Lingua::famibeib::Prefix->new(string => $str);

(since v0.06)

Constructs a new prefix. The prefix is normalised as part of this. This method might deduplicate instances. So not all instances might be new objects.

Currently the following types ($type) are supported:

from

(since v0.06)

Constructs a prefix from an object. $value should be a reference.

Currently references to the following types are supported: Data::Identifier, Data::Identifier::Interface::Simple, Data::URIID::Base, and Lingua::famibeib::Prefix. More types might be supported.

If $value is not a reference the value is parsed as per string if it looks like a prefix string (experimental since v0.06).

string

(since v0.06)

Constructs a prefix from it's string representation.

as_string

my $str = $prefix->as_string;

(since v0.06)

Returns the string representation of the prefix.

eq

my $bool = $prefix->eq($other); # $prefix must be non-undef
# or:
my $bool = Lingua::famibeib::Prefix::eq($prefix, $other); # $prefix can be undef

(since v0.06)

Compares two prefixes to be equal.

If both prefixes are undef they are considered equal.

If $prefix or $other is not an instance of Lingua::famibeib::Prefix or undef "new" with the type from is used.

The operators "eq" in perlop and "ne" in perlop are overloaded to this method.

cmp

my $val = $prefix->cmp($other); # $prefix must be non-undef
# or:
my $val = Lingua::famibeib::Prefix::cmp($prefix, $other); # $prefix can be undef

(experimental since v0.06)

Compares the prefixes similar to cmp. This method can be used to order prefixes. To check for them to be equal see "eq".

The parameters are parsed the same way as "eq".

The operator "cmp" in perlop is overloaded to this method.

If this method is used for sorting the exact resulting order is not defined. However:

  • The order is stable

  • The order is the same for $a->cmp($b) as for - $b->cmp($a).

register

$prefix->register;

(since v0.06)

Registers the prefix with this module. A registered prefix will be kept in memory indefinitely. It is used for deduplication and some types of lookups.

This method will return $prefix. This can be used to build constants.

Note: Calling this multiple times on the same prefix is fine. However, doing so might waste some time.

Note: It is undefined (since v0.06) whether or not this will also register the corresponding Data::Identifier.

AUTHOR

Philipp Schafft <lion@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2025-2026 by Philipp Schafft <lion@cpan.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)