Apache2-ASP
view release on metacpan or search on metacpan
lib/Apache2/ASP/Server.pm view on Meta::CPAN
utf8::encode($u); # drop utf8 flag
return $u;
}# end _utf8_chr()
#==============================================================================
sub DESTROY
{
my $s = shift;
undef(%$s);
}# end DESTROY()
1;# return true:
=pod
=head1 NAME
Apache2::ASP::Server - Utility methods for Apache2::ASP
=head1 SYNOPSIS
my $full_path = $Server->MapPath('/index.asp');
$Server->URLEncode( 'user@email.com' );
$Server->URLDecode( 'user%40email.com' );
$Server->HTMLEncode( '<br />' );
$Server->HTMLDecode( '<br />' );
$Server->Mail(
To => 'user@email.com',
From => '"Friendly Name" <friendly.name@email.com>',
Subject => 'Hello World',
Message => "E Pluribus Unum.\n"x777
);
$Server->RegisterCleanup( sub {
my @args = @_;
...
}, @args
);
=head1 DESCRIPTION
The ASP Server object is historically a wrapper for a few utility functions that
don't belong anywhere else.
Keeping with that tradition, the Apache2::ASP Server object is a collection of
functions that don't belong anywhere else.
=head1 PUBLIC METHODS
=head2 URLEncode( $str )
Converts a string into its url-encoded equivalent. This approximates to
JavaScript's C<escape()> function or L<CGI>'s C<escape()> function.
Example:
<%= $Server->URLEncode( 'user@email.com' ) %>
Returns
user%40email.com
=head2 URLDecode( $str )
Converts a url-encoded string into its non-url-encoded equivalent. This works
the same way as JavaScript's and L<CGI>'s C<unescape()> function.
Example:
<%= $Server->URLDecode( 'user%40email.com' ) %>
Returns
user@email.com
=head2 HTMLEncode( $str )
Safely converts <, > and & into C<<>, C<>> and C<&>, respectively.
=head2 HTMLDecode( $str )
Converts C<<>, C<>> and C<&> into <, > and &, respectively.
=head2 MapPath( $relative_path )
Given a relative path, C<MapPath> will return the absolute path for it, under the
document root of the current website.
For example, C</index.asp> might return C</usr/local/famicom/htdocs/index.asp>
=head2 Mail( %args )
Sends an email message. The following arguments are required:
=over 4
=item To
The email address the message should be sent to.
=item From
The email address the message should be sent from.
=item Subject
The subject of the email.
=item Message
The content of the body.
=back
Other arguments are passed through to L<Mail::Sendmail>.
=head2 RegisterCleanup( \&code[, @args ] )
A wrapper around L<APR::Pool>'s C<cleanup_register> function. Pass in a coderef
and (optionally) arguments to be passed to that coderef, and it is executed during
the cleanup phase of the current request.
If we were doing vanilla mod_perl, you could achieve the same effect with this:
$r->pool->cleanup_register( sub { ... }, \@args );
( run in 0.659 second using v1.01-cache-2.11-cpan-39bf76dae61 )