URI::Namespace(3pm)
β¨ 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, orundefif 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
- debian trixie: liburi-namespacemap-perl 1.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liburi-namespacemap-perl 1.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liburi-namespacemap-perl 1.12-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms