Afnic and IIS Zonemaster Project
and 1 contributors


Zonemaster::Engine::DNSName - class representing DNS names


    my $name1 = Zonemaster::Name->new('');
    my $name2 = Zonemaster::Name->new('');
    say "Yay!" if $name1->common($name2) == 2;



A reference to a list of strings, being the labels the DNS name is made up from.


new($input) _or_ new({ labels => \@labellist})

The constructor can be called with either a single argument or with a reference to a hash as in the example above.

If there is a single argument, it must be either a non-reference, a Zonemaster::Engine::DNSName object or a Zonemaster::Engine::Zone object.

If it's a non-reference, it will be split at period characters (possibly after stringification) and the resulting list used as the name's labels.

If it's a Zonemaster::Engine::DNSName object it will simply be returned.

If it's a Zonemaster::Engine::Zone object, the value of its name attribute will be returned.


Returns a string representation of the name. The string representation is created by joining the labels with dots. If there are no labels, a single dot is returned. The names created this way do not have a trailing dot.

The stringification operator is overloaded to this function, so it should rarely be necessary to call it directly.


Returns the name as a string complete with a trailing dot.


Overloads string comparison. Comparison is made after converting the names to upper case, and ignores any trailing dot on the other name.


Returns a new Zonemaster::Engine::DNSName object, representing the name of the called one with the leftmost label removed.


Returns the number of labels from the rightmost going left that are the same in both names. Used by the recursor to check for redirections going up the DNS tree.


Returns a new Zonemaster::Engine::DNSName object, representing the called one with the given label prepended.


Helper method for JSON encoding.