URI::FromHash(3pm)
π URI::FromHash β the manual, but make it slay π
okay bestie, listen. this is URI::FromHash, a Perl module, and its whole personality is build a URI from a set of named parameters. that's literally the NAME line and honestly? it ate. no cap. β¨
πΈ VERSION πΈ
version 0.05 β that's the one, that's the version, don't @ me π«Ά
π¦ SYNOPSIS π¦
here's the vibe, copy-paste ready:
use URI::FromHash qw( uri );
my $uri = uri(
path => '/some/path',
query => { foo => 1, bar => 2 },
);
that's it. that's the whole flex. π
β¨ DESCRIPTION β¨
so this module gives you a simple one-subroutine "named parameters" style interface for creating URIs. one sub. named params. immaculate.
underneath the hood it uses URI.pm, bestie β though because of the simplified interface it may not support all possible options for all types of URIs. so like, it's the cute approachable version, not the everything-everywhere version. know the difference. π
it was created for the common case where you simply want a simple interface for creating syntactically correct URIs from known components (like a path and query string). doing this using the native URI.pm interface is, and I quote, rather tedious β it requires a number of method calls, which is particularly ugly when done inside a templating system such as Mason or TT2. like imagine doing all that inside a template. not me. couldn't be me. π
π FUNCTIONS π
this module provides two functions and both of them are optionally exportable. pick your fave, or take both, we don't gatekeep.
π uri( ... ) and uri_object( ... ) π
both of these functions accept the same set of parameters β except for one additional parameter that's allowed when you call uri(). one lil bonus. a treat. π
uri()simply returns a string representing a canonicalized URI based on the provided parameters.uri_object()returns a newURI.pmobject based on the given parameters.
and these are the parameters, bestie, all of them, in order, no skipping:
schemeβ the URI's scheme. this one is optional, and if you don't give one you'll create a schemeless URI. which is genuinely useful when you want a URI to a path on the same server β exactly the kind of thing that commonly happens in<a>tags. iykyk. π«Άhostβ yeah. the host. πportβ the port, queen. πpathβ okay this one has layers. the path can be either a string or an array reference.- if an array reference is passed, each defined member of the array will be joined by a single forward slash (
/). - if you're building a host-less URI and you want a leading slash, then make the first element of the array reference an empty string (
q{}). - you can add a trailing slash by making the last element of the array reference an empty string.
- if an array reference is passed, each defined member of the array will be joined by a single forward slash (
see? layers. iconic behaviour honestly.
usernameβ a string. optional. πpasswordβ a string. optional. π₯fragmentβ all of these are optional strings which can be used to specify that part of the URI. yes, "all of these" includesusername,passwordandfragmentβ they're a little trio, they come as a set. πqueryβ this should be a hash reference of query parameters. the values for each key may be a scalar or an array reference β use an array reference when you want to provide multiple values for one key. so many values. so many keys. we love options. πquery_separatorβ β οΈ this option can only be provided when callinguri(). by default, it is a semi-colon (;). that's the default. don't forget it. β¨
π BUGS π
please report any bugs or feature requests to bug-uri-fromhash@rt.cpan.org, or through the web interface at <http://rt.cpan.org>. the author says: "I will be notified, and then you'll automatically be notified of progress on your bug as I make changes." so like, you will get updates. that's a whole feedback loop. slay. π¦
πΈ AUTHOR πΈ
Dave Rolsky <autarch@urth.org> β the author. the main character. give them their flowers. π
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2015 by Dave Rolsky.
this is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
periodt. legal said what it said. πβ¨
and that's the whole page, bestie π«Ά this was perl v5.34.0, dated 2022-06-28, and that's your URI::FromHash(3pm) β go build some URIs, you absolute legend. π
ππ
π¦ where this page comes from
- debian bookworm: liburi-fromhash-perl 0.05-2 Β· Artistic-2.0
- debian trixie: liburi-fromhash-perl 0.05-2 Β· Artistic-2.0
- ubuntu noble: liburi-fromhash-perl 0.05-2 Β· Artistic-2.0
- ubuntu resolute: liburi-fromhash-perl 0.05-2 Β· Artistic-2.0
- ubuntu stonking: liburi-fromhash-perl 0.05-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms