NAME
URLprocessor - Perl extension for object oriented URL address processing.
SYNOPSIS
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";
DESCRIPTION
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)
METHODS
You have an access to some useful methods:
- $url = URLprocessor->new( )
- $url = URLprocessor->new( $str )
-
Construct new URL object and return a reference to it. Every URL is translated to a lower case.
- $url->url
-
Get string representation of a URL object.
- $url->url_global_part
-
Get string representation of the global part of a URL object (protocol, login, password, host, port).
- $url->url_local_part
-
Get string representation of the global part of a URL object (local path, query, label).
- $url->protocol
- $url->protocol( $str )
- $url->protocol( undef )
-
Get and set a protocol. A string is translated to a lower case.
- $url->login
- $url->login( $str )
- $url->login( undef )
-
Get and set a login.
- $url->passwd
- $url->passwd( $str )
- $url->passwd( undef )
-
Get and set a passwd.
- $url->host
- $url->host( $str )
- $url->host( undef )
-
Get and set a host. The host is translated to a lower case.
- $url->port
- $url->port( $str )
- $url->port( undef )
-
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.
- $url->localpath
- $url->localpath( $str )
- $url->localpath( \@array )
- $url->localpath( undef )
-
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/')
- $url->localpath_array
-
Get an array of the parts of a local path.
- $url->fragment
- $url->fragment( $str )
- $url->fragment( undef )
-
Get and set a fragment. This is a part of a URL after '#'.
- $url->params_string
- $url->params_string( $str )
-
Get string representation of query parameters. You can prepare a string with $str delimiter (default is '&').
- $url->params_hash
- $url->params_hash( undef )
- $url->params_hash( \%params )
-
Get or set reference to a hash with query parameters (param => value).
- $url->param_value( $param_name )
-
Get the value of a parameter from a query.
- $url->param_add( $param_name, $param_val )
-
Set in a query the following pair: parameter=value. The parameter and value must be defined. Pay attention to the argument order!
- $url->param_del( $param_name )
-
Delete from a query the following pair: parameter=value
- $url->param_exist( $param_name )
-
Check if the pair parameter=value exists in a query.
- $url->valid_status
-
Get status from the validation of a URL object. If anything goes wrong return 0, else 1.
- $url->valid_msg
-
Get a message from the validation of a URL object.
SEE ALSO
AUTHOR
Pawel Koscielny, <koscielny.pawel@gmail.com>
COPYRIGHT AND LICENSE
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:
- Around line 447:
'=item' outside of any '=over'
- Around line 597:
You forgot a '=back' before '=head1'