The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache2::ASP::Server - Utility methods for Apache2::ASP

SYNOPSIS

  my $full_path = $Server->MapPath('/index.asp');
  
  $Server->URLEncode( 'user@email.com' );

  $Server->URLDecode( 'user%40email.com' );
  
  $Server->HTMLEncode( '<br />' );
  
  $Server->HTMLDecode( '&lt;br /&gt;' );
  
  $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
  );

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.

PUBLIC METHODS

URLEncode( $str )

Converts a string into its url-encoded equivalent. This approximates to JavaScript's escape() function or CGI's escape() function.

Example:

  <%= $Server->URLEncode( 'user@email.com' ) %>

Returns

  user%40email.com

URLDecode( $str )

Converts a url-encoded string into its non-url-encoded equivalent. This works the same way as JavaScript's and CGI's unescape() function.

Example:

  <%= $Server->URLDecode( 'user%40email.com' ) %>

Returns

  user@email.com

HTMLEncode( $str )

Safely converts <, > and & into &lt;, &gt; and &amp;, respectively.

HTMLDecode( $str )

Converts &lt;, &gt; and &amp; into <, > and &, respectively.

MapPath( $relative_path )

Given a relative path, MapPath will return the absolute path for it, under the document root of the current website.

For example, /index.asp might return /usr/local/famicom/htdocs/index.asp

Mail( %args )

Sends an email message. The following arguments are required:

To

The email address the message should be sent to.

From

The email address the message should be sent from.

Subject

The subject of the email.

Message

The content of the body.

Other arguments are passed through to Mail::Sendmail.

RegisterCleanup( \&code[, @args ] )

A wrapper around APR::Pool's 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 );

BUGS

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP to submit bug reports.

HOMEPAGE

Please visit the Apache2::ASP homepage at http://www.devstack.com/ to see examples of Apache2::ASP in action.

AUTHOR

John Drago <jdrago_999@yahoo.com>

COPYRIGHT

Copyright 2008 John Drago. All rights reserved.

LICENSE

This software is Free software and is licensed under the same terms as perl itself.