Zonema...DNSName(3pm)
π Zonemaster::DNSName β class representing DNS names π
okay bestie, welcome to Zonemaster::DNSName, the class that's literally just out here representing DNS names β¨ it's giving "I contain labels and I know it" π
this page is from the User Contributed Perl Documentation, and it's the Zonemaster::DNSName(3pm) joint, so let's get into it π«Ά
πΈ SYNOPSIS πΈ
look at this lil snack of a snippet, no cap:
my $name1 = Zonemaster::Name->new('www.example.org');
my $name2 = Zonemaster::Name->new('ns.example.org');
say "Yay!" if $name1->common($name2) == 2;
iconic. periodt.
π ATTRIBUTES π
labelsβ a reference to a list of strings, and those strings are the labels your DNS name is built out of π so like, the little pieces, you know? the way that a name is just labels stacked up? obsessed.
β¨ METHODS β¨
new($input)ornew({ labels => \@labellist})β the constructor, and she's flexible bestie π she takes either a single argument, or a reference to a hash, exactly like the example up in the synopsis.
so if you're passing a single argument, it has to be one of three things: a non-reference, a Zonemaster::DNSName object, or a Zonemaster::Zone object. no other options, that's the vibe check.
- if it's a non-reference, it gets split at period characters (possibly after stringification, fyi) and that resulting list becomes the name's labels π¦
- if it's a
Zonemaster::DNSNameobject, it just gets returned as-is. lowkey the easiest job ever π - if it's a
Zonemaster::Zoneobject, then the value of itsnameattribute gets returned π
string()β returns a string representation of the name π« that string is made by joining the labels together with dots. and if there are no labels at all? you get a single dot back. just one. lonely lil dot π
heads up tho: the names created this way do not have a trailing dot. nope, none.
also the stringification operator is overloaded to this function, so you'll rarely ever need to call it directly. she's working behind the scenes, main character energy fr fr π
fqdn()β returns the name as a string, complete with a trailing dot β¨ there's the dot, bestie, she's here.str_cmp($other)β overloads string comparison π₯ the comparison happens after converting the names to upper case, and it ignores any trailing dot on the other name. so like, don't come for her about case or that last dot, she's already handled it πnext_higher()β returns a newZonemaster::DNSNameobject representing the name of the called one, but with the leftmost label removed π¦ bye bye leftmost label, we hardly knew ye.common($other)β returns the number of labels, going from the rightmost one leftwards, that are the same in both names π―ββοΈ this is what the recursor uses to check for redirections going up the DNS tree, iykyk.prepend($label)β returns a newZonemaster::DNSNameobject representing the called one with the given label prepended π yes queen, put that label at the front.TO_JSONβ helper method for JSON encoding π that's the whole description, she's mysterious, she's efficient, we respect it.
π reminder bestie:next_higher()andprepend()both hand you back a new object, they don't mutate the one you called them on. no cap.
and that's the whole page, babe π this was Zonemaster...DNSName(3pm) from the User Contributed Perl Documentation, shipped with perl v5.32.0, dated 2021-01-06 π mwah, go write some DNS names, you got this ππΈ
π¦ where this page comes from
- ubuntu jammy: libzonemaster-perl 1.0.16-2.1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms