URLprocessor - Perl extension for object oriented URL address processing.
use URLprocessor; $url = URLprocessor->new('http://login:passwd@www.cpan.org:8080/local/path/file.php?param=val¶m2=val2#some_fragment'); $url->port(80); $url->fragment('some_other_fragment'); $url->param_add('newparam', 'newvalue'); $url->param_del('param2'); print $url->valid_status(), "\n"; print $url->valid_msg(), "\n"; print $url->login(), "\n"; print $url->host(), "\n"; print $url->url(), "\n";
This module contains a class with implementation for representing a URL address. You can read and write each part of a URL object. This class implements methods for the validation of a URL. You can build your own URL or modify an already existing object.
A right URL must contain:
protocol (scheme) host
Optional parts of a URL:
login and passwd port local path
Optional parts of a local path:
parameters (query) fragment (label)
You have an access to some useful methods:
Construct new URL object and return a reference to it. Every URL is translated to a lower case.
Get string representation of a URL object.
Get string representation of the global part of a URL object (protocol, login, password, host, port).
Get string representation of the global part of a URL object (local path, query, label).
Get and set a protocol. A string is translated to a lower case.
Get and set a login.
Get and set a passwd.
Get and set a host. The host is translated to a lower case.
Get and set a port. Here you can write anything but remember that the port must be a numeric value. If not, valid_status return 0.
Get and set a local path (with file, without query). Only SCALAR, ARRAY and undef are allowed to set the localpath. You should remember about '/' at the end of @array if it is a directory. For example:
@array = ('dir1', 'dir2', 'dir3/')
Get an array of the parts of a local path.
Get and set a fragment. This is a part of a URL after '#'.
Get string representation of query parameters. You can prepare a string with $str delimiter (default is '&').
Get or set reference to a hash with query parameters (param => value).
Get the value of a parameter from a query.
Set in a query the following pair: parameter=value. The parameter and value must be defined. Pay attention to the argument order!
Delete from a query the following pair: parameter=value
Check if the pair parameter=value exists in a query.
Get status from the validation of a URL object. If anything goes wrong return 0, else 1.
Get a message from the validation of a URL object.
URI, URI::URL, Rose::URI
Pawel Koscielny, <koscielny.pawel@gmail.com>
Copyright (C) 2011 by Pawel Koscielny
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install URLprocessor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm URLprocessor
CPAN shell
perl -MCPAN -e shell install URLprocessor
For more information on module installation, please visit the detailed CPAN module installation guide.