URI::Namespace(3pm)

πŸ“¦
version 1.12 Β· 6 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ URI::Namespace ✨

okay bestie, welcome to URI::Namespace πŸ’– this is the User Contributed Perl Documentation page for it, and by the end you're gonna be besties with namespaces, fr fr.


🌸 NAME 🌸

URI::Namespace β€” a namespace URI/IRI class with autoload methods πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

use URI::Namespace;
my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' );
print $foaf->as_string;
print $foaf->name;

like... it's giving "three lines and you're done" πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

So this module hands you an object with a URI/IRI attribute β€” typically used for prefix-namespace pairs, the kind you see in XML, RDF serializations, etc. (iykyk 🌈).

And here's the iconic part: the local part can be used as a method, and those methods are autoloaded. no cap. you literally just call it. 😭✨


πŸ‘‘ METHODS πŸ‘‘

  • new ( $string | URI | IRI ) β€” the constructor, bestie 🫢 you can pass it a string with a URI, or a URI object.
  • uri ( [ $local_part ] ) β€” returns a URI object with the namespace IRI. optionally it can take a local part as an argument, and then it returns the namespace URI with the local part appended. slay.
  • iri ( [ $local_part ] ) β€” same energy, but returns an IRI object with the namespace IRI 🌸. optionally takes a local part as argument, and then it returns the namespace IRI with the local part appended.
  • local_part ( $uri ) β€” returns the local part string if the given argument URI matches the namespace URI, or undef if not πŸ™ˆ. the argument URI can be a string, URI or IRI object, so it's flexible like that.

The following methods from URI can be used on an URI::Namespace object: as_string, as_iri, canonical, eq, abs, rel. ⭐ keep that list, it's a vibe check for what you get for free.


One important usage for this module is to enable you to create URIs for full URIs, e.g.:

print $foaf->Person->as_string;

will return

http://xmlns.com/foaf/0.1/Person
ok so that right there is the main character moment πŸ”₯ autoload said "I got you" and appended your local part. literally iconic.

πŸ¦‹ FURTHER DETAILS πŸ¦‹

See URI::NamespaceMap for further details about authors, license, etc. πŸ’– (yes bestie, the receipts live over there)


and that's the whole page! this one shipped with perl v5.38.2, dated 2024-08-03, and it's filed under URI::Namespace(3pm). mwah πŸ’…βœ¨ go forth and namespace responsibly πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from