NAME
URI::FromHash - The fantastic new URI::FromHash!
SYNOPSIS
Perhaps a little code snippet.
use URI::FromHash;
my $foo = URI::FromHash->new;
DESCRIPTION
This module provides a simple functional "named parameters" style interface for creating URIs. Underneath the hood it uses URI.pm
, though because of the simplified interface it may not support all possible options for all types of URIs.
It was created for the common case where you simply want to have 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 rather tedious, requiring a number of method calls, which is particularly ugly when done inside a templating system such as Mason or TT2.
FUNCTIONS
This module provides two functions both of which are optionally exportable:
uri( ... )
uri_object( ... )
Both of these functions accept the same set of parameters, except for one additional parameter allowed when calling
uri()
.The
uri()
function simply returns a string representing a canonicalized URI based on the provided parameters. Theuri_object()
function returns new aURI.pm
object based on the given parameters.These parameters are:
- o scheme
-
The URI's scheme. This is optional, and if none is given you will create a schemeless URI. This is useful if you want to create a URI to a path on the same server (as is commonly done in
<a>
tags). - o host
- o port
- o path
- o username
- o password
- o fragment
-
All of these are optional strings which can be used to specify that part of the URI.
- o query
-
This should be a hash reference of query parameters. The values for each key may be a scalar or array reference. Use an array reference to provide multiple values for one key.
- o query_separator
-
This option is can only be provided when calling
uri()
. By default, it is a semi-colon (;).
AUTHOR
Dave Rolsky, <autarch@urth.org>
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. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2006 Dave Rolsky, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.