Zonema...DNSName(3pm)

πŸ“¦ version 1.0.16, in ubuntu jammy

πŸ’– 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) or new({ 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::DNSName object, it just gets returned as-is. lowkey the easiest job ever 😭
  • if it's a Zonemaster::Zone object, then the value of its name attribute 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 new Zonemaster::DNSName object 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 new Zonemaster::DNSName object 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() and prepend() 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