Net::RD...:Address(3)

๐Ÿ“ฆ
version 0.43 ยท 3 versions
, in fedora 44

๐Ÿ’Œ NAME ๐Ÿ’Œ

Net::RDAP::JCard::Address โ€” it's a module, bestie, and it represents a postal address inside a Net::RDAP::JCard object. That's it, that's the job. ๐Ÿ’…

Oh and btw, this whole thing is a page from the User Contributed Perl Documentation section, so you know it's the real deal. โœจ


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

okay so first you gotta get the jcard, like so:

#
# get an object by calling the jcard() method on a Net::RDAP::Object::Entity
#
my $jcard = $entity->jcard;

#
# get the first address. You can also uses $jcard->addresses() to get all
# ADR properties.
#
my $adr = $jcard->first_address;

if ($adr->structured) {
    #
    # This is a structured address so we can extract the individual components:
    #

    map { say "Street: ".$_ } @{$adr->street};
    say "Locality: ".$adr->locality;
    say "Region: ".$adr->region;
    say "Postal Code: ".$adr->code;
    say "Country: ".($adr->cc || $adr->country);

} else {
    #
    # This is an unstructured address, so just print it:
    #
    say "Address:".$adr->address;

}

see how there's two whole vibes in there? structured addresses let you pull out every little piece, and unstructured ones you just print as-is. both valid. both slay. ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so. postal addresses. the vCard representation (<https://www.rfc-editor.org/rfc/rfc6350.html#section-6.3.1>) and the jCard representation (<https://datatracker.ietf.org/doc/html/rfc7095#section-3.3.1.3>) are... a lot. like, genuinely a struggle. they are hard to deal with and they cause difficulties, and that's just the truth of it. ๐Ÿ˜ญ

so Net::RDAP::JCard::Address swoops in with an ergonomic interface to "ADR" properties inside jCard objects. your wrists will thank you.

and to actually get one of these bad boys? use the first_address() or addresses() methods of Net::RDAP::JCard โ€” they hand you back an array of address objects. ๐ŸŽ€


๐Ÿ‘‘ METHODS ๐Ÿ‘‘

Net::RDAP::JCard::Address inherits from Net::RDAP::JCard::Property, so it's already got all of that module's methods (iconic behaviour, honestly), plus everything below. ๐Ÿ‘‡

โœจ ADDRESS TYPE โœจ

$structured = $adr->structured;

returns true if the address is "structured" โ€” and if you want the full lore on that, it's Section 3.3.1.3 of RFC 7095 (<https://datatracker.ietf.org/doc/html/rfc7095#section-3.3.1.3>). ๐Ÿ“–

๐ŸŽ€ FLAT ADDRESS ๐ŸŽ€

say $adr->address;

hands you back a multi-line text string with the whole address in it. and listen โ€” for "unstructured" addresses this is the only format available, so it's literally the simplest way to display the address info. no cap. ๐ŸŒˆ

๐Ÿ“ฎ P.O. BOX NUMBER ๐Ÿ“ฎ

say $adr->pobox;

returns the Post Office box number, or "undef". (and yeah, "undef" is always an option, she's flexible like that.) ๐Ÿ™ˆ

๐Ÿข EXTENDED ADDRESS ๐Ÿข

say $adr->extended;

returns the "extended" address component โ€” you know, the apartment number, the suite number, that whole situation โ€” or "undef". ๐Ÿ’œ

๐Ÿ›ฃ๏ธ STREET ADDRESS ๐Ÿ›ฃ๏ธ

map { say $_ } @{$adr->street};

okay so some structured addresses have just one street address, but some have multiple street addresses, and those get represented as an arrayref. the way that works is lowkey important.

this method will always return an arrayref, bestie, and that arrayref may contain zero, one, or many values. plan accordingly. ๐Ÿ’…

๐Ÿ˜๏ธ LOCALITY ๐Ÿ˜๏ธ

say $adr->locality;

returns the locality, or "undef". โญ

๐Ÿ—บ๏ธ REGION ๐Ÿ—บ๏ธ

say $adr->region;

returns the region, or "undef". ๐ŸŒธ

๐Ÿ“ฌ POSTAL CODE ๐Ÿ“ฌ

say $adr->code;

returns the postal code, or "undef". ๐Ÿ“

๐ŸŒ COUNTRY CODE ๐ŸŒ

say $adr->cc;

returns the ISO-3166-alpha2 country code โ€” full details in Section 3.1 of RFC 8605 (<https://www.rfc-editor.org/rfc/rfc8605.html#section-3.1>) โ€” or "undef". ๐Ÿ”ฅ

๐Ÿณ๏ธ COUNTRY NAME ๐Ÿณ๏ธ

say $adr->country;

returns the country name, or "undef". ๐Ÿฆ‹


Copyright 2018-2023 CentralNic Ltd, 2024-2026 Gavin Brown. For licensing information, please see the "LICENSE" file in the Net::RDAP distribution. ๐Ÿ’–


k bye bestie, go forth and parse some addresses ๐Ÿ’…

perl v5.42.2 ๐Ÿฉท 2026-06-17 โ€” that's the version and the date this lil page was born, and honestly? ate. ๐ŸŒˆโœจ

๐Ÿ“ฆ where this page comes from