Apache::Util - Interface to Apache C util functions
SYNOPSIS
use Apache::Util qw(:all);
DESCRIPTION
This module provides a Perl interface to some of the C utility functions
available in Perl. The same functionality is avaliable in libwww-perl, but
the C versions are faster:
use Benchmark;
timethese(1000, {
C => sub { my $esc = Apache::Util::escape_html($html) },
Perl => sub { my $esc = HTML::Entities::encode($html) },
});
This routine replaces unsafe characters in $string with their entity
representation.
my $esc = Apache::Util::escape_html($html);
escape_uri
This function replaces all unsafe characters in the $string with their
escape sequence and returns the result.
my $esc = Apache::Util::escape_uri($uri);
unescape_uri
This function decodes all %XX hex escape sequences in the given URI.
my $unescaped = Apache::Util::unescape_uri($safe_uri);
unescape_uri_info
This function is similar to unescape_uri() but is specialized to remove
escape sequences from the query string portion of the URI. The main
difference is that it translates the ``+'' character into spaces as well
as recognizing and translating the hex escapes.
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
Example:
my $secs = Apache::Util::parsedate($date_str);
ht_time
Format a time string.
Examples:
my $str = Apache::Util::ht_time(time);
my $str = Apache::Util::ht_time(time, "%d %b %Y %T %Z");
my $str = Apache::Util::ht_time(time, "%d %b %Y %T %Z", 0);
size_string
Converts the given file size into a formatted string. The size
given in the string will be in units of bytes, kilobytes, or
megabytes, depending on the size.
my $size = Apache::Util::size_string -s $r->finfo;
validate_password
Validate a plaintext password against a smashed one. Use either
crypt() (if available), ap_MD5Encode() or ap_SHA1Encode depending
upon the format of the smashed input password.