CGI-Utils
view release on metacpan or search on metacpan
my $file_name = "$file_handle";
DESCRIPTION
This module can be used almost as a drop-in replacement for CGI.pm for
those of you who do not use the HTML generating features of CGI.pm
This module provides an object-oriented interface for retrieving
information provided by the Common Gateway Interface, as well as
url-encoding and decoding values, and parsing CGI parameters. For
example, CGI has a utility for escaping HTML, but no public interface
for url-encoding a value or for taking a hash of values and returning a
url-encoded query string suitable for passing to a CGI script. This
module does that, as well as provide methods for creating a
self-referencing url, converting relative urls to absolute, adding CGI
parameters to the end of a url, etc. Please see the METHODS section
below for more detailed descriptions of functionality provided by this
module.
File uploads via the multipart/form-data encoding are supported. The
parameter for the field name corresponding to the file is a file handle
that, when evaluated in string context, returns the name of the file
uploaded. To get the contents of the file, just read from the file
handle.
mod_perl is supported if a value for apache_request is passed to new(),
or if the apache request object is available via Apache->request, or if
running under HTML::Mason. See the documentation for the new() method
for details.
If not running in a mod_perl or CGI environment, @ARGV will be searched
for key/value pairs in the format
key1=val1 key2=val2
If all command-line arguments are in this format, the key/value pairs
will be available as if they were passed via a CGI or mod_perl
interface.
METHODS
new(\%params)
Returns a new CGI::Utils object. Parameters are optional. CGI::Utils
supports mod_perl if the Apache request object is passed as
$params{apache_request}, or if it is available via Apache->request (or
Apache2::RequestUtil->request), or if running under HTML::Mason.
You may also pass max_post_size in %params.
urlEncode($str)
Returns the fully URL-encoded version of the given string. It does not
convert space characters to '+' characters.
Aliases: url_encode()
urlUnicodeEncode($str)
Returns the fully URL-encoded version of the given string as unicode
characters. It does not convert space characters to '+' characters.
Aliases: url_unicode_encode()
urlDecode($url_encoded_str)
Returns the decoded version of the given URL-encoded string.
Aliases: url_decode()
urlUnicodeDecode($url_encoded_str)
Returns the decoded version of the given URL-encoded string, with
unicode support.
Aliases: url_unicode_decode()
urlEncodeVars($var_hash, $sep)
Takes a hash of name/value pairs and returns a fully URL-encoded query
string suitable for passing in a URL. By default, uses the newer
separator, a semicolon, as recommended by the W3C. If you pass in a
second argument, it is used as the separator between key/value pairs.
Aliases: url_encode_vars()
urlDecodeVars($query_string)
Takes a URL-encoded query string, decodes it, and returns a reference to
a hash of name/value pairs. For multivalued fields, the value is an
array of values. If called in array context, it returns a reference to a
hash of name/value pairs, and a reference to an array of field names in
the order they appear in the query string.
Aliases: url_decode_vars()
escapeHtml($text)
Escapes the given text so that it is not interpreted as HTML. &, <, >,
and " characters are escaped.
Aliases: escape_html()
escapeHtmlFormValue($text)
Escapes the given text so that it is valid to put in a form field.
Aliases: escape_html_form_value()
getSelfRefHostUrl()
Returns a url referencing top level directory in the current domain,
e.g., http://mydomain.com
Aliases: get_self_ref_host_url()
getSelfRefUrl()
Returns a url referencing the current script (without any query string).
Aliases: get_self_ref_url
getSelfRefUri()
Returns the current URI.
Aliases: get_self_ref_uri()
getSelfRefUrlWithQuery()
Returns a url referencing the current script along with any query string
parameters passed via a GET method.
Aliases: get_self_ref_url_with_query()
getSelfRefUrlWithParams($params, $sep)
Returns a url reference the current script along with the given hash of
parameters added onto the end of url as a query string.
If the optional $sep parameter is passed, it is used as the parameter
separator instead of ';', unless the URL already contains '&' chars, in
( run in 1.403 second using v1.01-cache-2.11-cpan-39bf76dae61 )