Eve::Uri - a URI automation class.
use Eve::Uri; my $uri = Eve::Uri->new( string => 'http://domain.com/path/script?foo=bar&baz=1&baz=2'); my $string = $uri->string; my $host = $uri->host; my $fragment = $uri->fragment; my $query_string = $uri->query; my $query_parameter = $uri->get_query_parameter(name => 'foo'); my @query_parameter_list = $uri->get_query_parameter(name => 'baz'); $uri->set_query_parameter(name => 'foo', value => 'some'); $uri->set_query_parameter(name => 'baz', value => [3, 4]); $uri->set_query_hash(hash => {'name' => 'foo', 'value' => 'some'}); $uri->set_query_hash( hash => {'name' => 'foo', 'value' => 'some'}, delimiter => '&'); my $query_hash = $uri->get_query_hash(); my $another_uri = $uri->clone(); my $matches_hash = $uri->match($another_uri) # empty hash - no placeholders $another_uri->query = 'another=query'; $matches_hash = $uri->match($another_uri); # undef $another_uri->path_concat('/some/deeper/path'); my $placeholder_uri = Eve::Uri->new( string => 'http://domain.com/:placeholder/:another'); my $substituted_uri = $placeholder_uri->substitute( hash => { 'placeholder' => 'first_value', 'another' => 'another_value'}); print $substituted_uri->string; # http://domain.com/first_value/another_value my $uri_is_relative = $uri->is_relative();
The class provides automation for different common operations with URIs. A URI is automaticaly brought to the canonical form after creation or after using any setter method.
fragment
a fragment part of the URI.
query
a query string part of the URI
string
an URI as a string
a string that can contain placeholders that are preceded with a semicolon character (':').
Clones and returns the object.
The object identical to self.
Matches self against other URI.
uri
a URI instance to match with.
If it matches then a substitutions hash is returned, otherwise - undef. If no placeholders in the URI empty hash is returned. Note that the method ignores query and fragment parts of URI.
Concatenates the url path with another path.
Substitutes values to the URI placeholders.
hash
a hash of substitutions.
Eve::Error::Value
when not enough or redundant substitutions are specified.
Returns a query parameter value for a certain parameter name.
name
Sets a query parameter value or a list of values for a certain parameter name.
value
If a scalar value is passed, it is assigned as a single value for the parameter name. If a list reference is passed, the parameter is assigned as a list.
Gets query string parameters as a hash.
Sets query string parameters as a hash.
delimiter
Returns 0 or 1 depending on the URI.
1
the URI is relative, e.g. /some/path
/some/path
0
the URI is absolute, e.g. http://example.com
http://example.com
URI
Copyright 2012 Igor Zinovyev.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Eve, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Eve
CPAN shell
perl -MCPAN -e shell install Eve
For more information on module installation, please visit the detailed CPAN module installation guide.