Apache-ASP
view release on metacpan or search on metacpan
or buy the mod_perl Eagle book. Some commonly used ones are:
PerlInitHandler
PerlTransHandler
PerlFixupHandler
PerlHandler
PerlLogHandler
PerlCleanupHandler
For straight Apache::ASP programming, there are some
equivalents, say Script_OnStart event instead of Init/Fixup
stages, or $Server->RegisterCleanup() for Log/Cleanup stages,
but you can do things in the mod_perl handlers that you
cannot do in Apache::ASP, especially if you want to handle
all files globally, and not just ASP scripts.
For many Apache::* modules for use with mod_perl, of which
Apache::ASP is just one, check out
http://perl.apache.org/src/apache-modlist.html
To gain access to the ASP objects like $Session outside
SMTP server is not available, this will have a return value of 0.
You could send an email like so:
$Server->Mail({
To => 'somebody@yourdomain.com.foobar',
From => 'youremail@yourdomain.com.foobar',
Subject => 'Subject of Email',
Body =>
'Body of message. '.
'You might have a lot to say here!',
Organization => 'Your Organization',
CC => 'youremailcc@yourdomain.com.foobar',
BCC => 'youremailbcc@yourdomain.com.foobar',
Debug => 0 || 1,
});
Any extra fields specified for the email will be interpreted
as headers for the email, so to send an HTML email, you
could set 'Content-Type' => 'text/html' in the above example.
Before XML, there was the need to make HTML markup smarter.
Apache::ASP gives you the ability to have a perl
subroutine handle the execution of any predefined tag,
taking the tag descriptors, and the text contained between,
as arguments of the subroutine. This custom tag
technology can be used to extend a web developer's abilities
to add dynamic pieces without having to visibly use
<% %> style code entries.
So, lets say that you have a table that
you want to insert for an employee with contact
info and the like, you could set up a tag like:
<my:new-employee name="Jane" last="Doe" phone="555-2222">
Jane Doe has been here since 1998.
</my:new-employee>
To render it with a custom tag, you would tell
the Apache::ASP parser to render the tag with a
subroutine:
http://perldoc.perl.org/perlobj.html
=head2 Use global.asa's Script_On* Events
Chances are that you will find yourself doing the same thing repeatedly
in each of your web application's scripts. You can use Script_OnStart
and Script_OnEnd to automate these routine tasks. These events are
called before and after each script request.
For example, let's say you have a header & footer you would like to
include in the output of every page, then you might:
# global.asa
sub Script_OnStart {
$Response->Include('header.inc');
}
sub Script_OnEnd {
$Response->Include('footer.inc');
}
Or let's say you want to initialize a global database connection
for use in your scripts:
# global.asa
use Apache::DBI; # automatic persistent database connections
use DBI;
use vars qw($dbh); # declare global $dbh
sub Script_OnStart {
# initialize $dbh
-- Richard Ward, HOSTING 321, LLC.
=item Concept Online Ltd.
=begin html
<a href=http://www.conceptonline.com><img src=concept_online.gif border=0></a>
=end html
I would like to say that your ASP module rocks :-) We have practically stopped developing in anything else about half a year ago, and are now using Apache::ASP extensively. I just love Perl, and whereever we are not "forced" to use JSP, we chose ASP....
-- Csongor Fagyal, Concept Online Ltd.
=item WebTime
=begin html
<a href="http://webtime-project.net"><img border=0 src="webtimelogo.jpg"></a>
=end html
traditional PHP users to the world of perl afficionados.
Having the possibility to use Apache::ASP with mod_perl or mod_cgi make
it constraintless to use because of CGI's universality and perl's
portability.
-- Grégoire Lejeune
=item David Kulp
First, I just want to say that I am very very impressed with Apache::ASP. I
just want to gush with praise after looking at many other implementations of
perl embedded code and being very underwhelmed. This is so damn slick and
clean. Kudos! ...
... I'm very pleased how quickly I've been able to mock
up the application. I've been writing Perl CGI off and on since 1993(!)
and I can tell you that Apache::ASP is a pleasure. (Last year I tried
Zope and just about threw my computer out the window.)
-- David Kulp
0.
You could send an email like so:
$Server->Mail({
To => 'somebody@yourdomain.com.foobar',
From => 'youremail@yourdomain.com.foobar',
Subject => 'Subject of Email',
Body =>
'Body of message. '.
'You might have a lot to say here!',
Organization => 'Your Organization',
CC => 'youremailcc@yourdomain.com.foobar',
BCC => 'youremailbcc@yourdomain.com.foobar',
Debug => 0 || 1,
});
Any extra fields specified for the email will be interpreted as headers
for the email, so to send an HTML email, you could set 'Content-Type' =>
'text/html' in the above example.
XML/XSLT
Custom Tags with XMLSubsMatch
Before XML, there was the need to make HTML markup smarter. Apache::ASP
gives you the ability to have a perl subroutine handle the execution of any
predefined tag, taking the tag descriptors, and the text contained between,
as arguments of the subroutine. This custom tag technology can be used to
extend a web developer's abilities to add dynamic pieces without having to
visibly use <% %> style code entries.
So, lets say that you have a table that you want to insert for an employee
with contact info and the like, you could set up a tag like:
<my:new-employee name="Jane" last="Doe" phone="555-2222">
Jane Doe has been here since 1998.
</my:new-employee>
To render it with a custom tag, you would tell the Apache::ASP parser to
render the tag with a subroutine:
PerlSetVar XMLSubsMatch my:new-employee
scripts. For more on perl objects & modules, please see:
http://perldoc.perl.org/perlobj.html
Use global.asa's Script_On* Events
Chances are that you will find yourself doing the same thing repeatedly in
each of your web application's scripts. You can use Script_OnStart and
Script_OnEnd to automate these routine tasks. These events are called before
and after each script request.
For example, let's say you have a header & footer you would like to include
in the output of every page, then you might:
# global.asa
sub Script_OnStart {
$Response->Include('header.inc');
}
sub Script_OnEnd {
$Response->Include('footer.inc');
}
Or let's say you want to initialize a global database connection for use in
your scripts:
# global.asa
use Apache::DBI; # automatic persistent database connections
use DBI;
use vars qw($dbh); # declare global $dbh
sub Script_OnStart {
# initialize $dbh
it's faster than before. Installation was a snap on our 25-server web
farm with a small shell script and everything is running perfectly! The
documentation is very comprehensive and everyone has been very helpful
during this migration.
Thank you!
-- Richard Ward, HOSTING 321, LLC.
Concept Online Ltd.
I would like to say that your ASP module rocks :-) We have practically
stopped developing in anything else about half a year ago, and are now
using Apache::ASP extensively. I just love Perl, and whereever we are
not "forced" to use JSP, we chose ASP. It is fast, reliable, versatile,
documented in a way that is the best for professionals - so thank you
for writting and maintaining it!
-- Csongor Fagyal, Concept Online Ltd.
WebTime
As we have seen with WebTime, Apache::ASP is not only good for the
I first discoverd it, I made it a must-have in my society by taking
traditional PHP users to the world of perl afficionados.
Having the possibility to use Apache::ASP with mod_perl or mod_cgi make
it constraintless to use because of CGI's universality and perl's
portability.
-- Grégoire Lejeune
David Kulp
First, I just want to say that I am very very impressed with
Apache::ASP. I just want to gush with praise after looking at many other
implementations of perl embedded code and being very underwhelmed. This
is so damn slick and clean. Kudos! ...
... I'm very pleased how quickly I've been able to mock up the
application. I've been writing Perl CGI off and on since 1993(!) and I
can tell you that Apache::ASP is a pleasure. (Last year I tried Zope and
just about threw my computer out the window.)
-- David Kulp
lib/Apache/ASP/Request.pm view on Meta::CPAN
sub ParseParams {
my($self, $string) = @_;
($string = $$string) if ref($string); ## faster if we pass a ref for a big string
my %params;
defined($string) || return(\%params);
my @params = split /[\&\;]/, $string, -1;
# we have to iterate through the params here to collect multiple values for
# the same param, say from a multiple select statement
for my $pair (@params) {
my($key, $value) = map {
# inline for greater efficiency
# &Unescape($self, $_)
my $todecode = $_;
$todecode =~ tr/+/ /; # pluses become spaces
$todecode =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/ge;
$todecode;
} split (/\=/, $pair, 2);
if(defined $params{$key}) {
site/articles/perlmonth1_intro.html view on Meta::CPAN
When developing a web site under ASP, one has access to a complete
set of objects and events, my favorite being $Session, which was one of ASP's
key selling points for me. $Session is ASP's answer to the problem of HTTP being a
stateless protocol. By using temporary session cookies, each web user
has a unique $Session in which you may store data, and that follows them from
script to script. Because the data storage
for $Session is handled on the server, you do not have to worry about
size limits of cookies as an alternate mechanism of storing user session data.
<p>
There are some very useful events as well. Let's say that you are
using <tt>$Session->{login}</tt> to control a user account login and logout. Because
$Session automatically times out every SessionTimeout, if a user
walks away from her/his computer for SessionTimeout minutes, the
<tt>$Session->{login}</tt> is destroyed along with the rest of the data stored in
$Session, and the next person that uses the computer will find themselves
automatically logged out from the account. This is a huge security win if
you maintain a set of accounts at your web site that hold sensitive information like
credit card numbers.
<p>
Here is a basic listing of the built-in <a href=http://www.apache-asp.org/objects.html>objects</a>
site/events.html view on Meta::CPAN
Apache event stages, for full list try "perldoc mod_perl"
or buy the mod_perl Eagle book. Some commonly used ones are:
<font face="courier new" size=3><pre>
PerlInitHandler
PerlTransHandler
PerlFixupHandler
PerlHandler
PerlLogHandler
PerlCleanupHandler
</pre></font>For straight Apache::ASP programming, there are some
equivalents, say Script_OnStart event instead of Init/Fixup
stages, or $Server->RegisterCleanup() for Log/Cleanup stages,
but you can do things in the mod_perl handlers that you
cannot do in Apache::ASP, especially if you want to handle
all files globally, and not just ASP scripts.
<font face="courier new" size=3><pre>
</pre></font>For many Apache::* modules for use with mod_perl, of which
Apache::ASP is just one, check out
<a href=http://perl.apache.org/src/apache-modlist.html>http://perl.apache.org/src/apache-modlist.html</a>
<font face="courier new" size=3><pre>
</pre></font>To gain access to the ASP objects like $Session outside
site/objects.html view on Meta::CPAN
SMTP server is not available, this will have a return value of 0.
<font face="courier new" size=3><pre>
</pre></font>You could send an email like so:
<font face="courier new" size=3><pre>
$Server->Mail({
To => '<b>somebody@yourdomain.com.foobar</b>',
From => '<b>youremail@yourdomain.com.foobar</b>',
Subject => 'Subject of Email',
Body =>
'Body of message. '.
'You might have a lot to say here!',
Organization => 'Your Organization',
CC => '<b>youremailcc@yourdomain.com.foobar</b>',
BCC => '<b>youremailbcc@yourdomain.com.foobar</b>',
Debug => 0 || 1,
});
</pre></font>Any extra fields specified for the email will be interpreted
as headers for the email, so to send an HTML email, you
could set 'Content-Type' => 'text/html' in the above example.
<font face="courier new" size=3><pre>
</pre></font>If you have MailFrom configured, this will be the default
site/style.html view on Meta::CPAN
<p>
<a name=Use%20global.ae21f52dc></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Use global.asa's Script_On* Events</b></font>
<font face="courier new" size=3><pre>
</pre></font>Chances are that you will find yourself doing the same thing repeatedly
in each of your web application's scripts. You can use Script_OnStart
and Script_OnEnd to automate these routine tasks. These events are
called before and after each script request.
<font face="courier new" size=3><pre>
</pre></font>For example, let's say you have a header & footer you would like to
include in the output of every page, then you might:
<font face="courier new" size=3><pre>
# global.asa
sub Script_OnStart {
$Response->Include('header.inc');
}
sub Script_OnEnd {
$Response->Include('footer.inc');
}
</pre></font>Or let's say you want to initialize a global database connection
for use in your scripts:
<font face="courier new" size=3><pre>
# global.asa
use Apache::DBI; # automatic persistent database connections
use DBI;
use vars qw($dbh); # declare global $dbh
sub Script_OnStart {
# initialize $dbh
site/testimonials.html view on Meta::CPAN
<font face="courier new" size=3><pre>
-- Richard Ward, HOSTING 321, LLC.
</pre></font>
<p>
<a name=Concept%20Onli9b9ce434></a>
<font face=verdana><font class=title size=+0 color=#555555><b>Concept Online Ltd.</b></font>
<font face="courier new" size=3><pre>
</pre></font><a href=http://www.conceptonline.com><img src=concept_online.gif border=0></a>
<font face="courier new" size=3><pre>
</pre></font>I would like to say that your ASP module rocks :-) We have practically stopped developing in anything else about half a year ago, and are now using Apache::ASP extensively. I just love Perl, and whereever we are not "forced" to...
<font face="courier new" size=3><pre>
-- Csongor Fagyal, Concept Online Ltd.
</pre></font>
<p>
<a name=WebTime></a>
<font face=verdana><font class=title size=+0 color=#555555><b>WebTime</b></font>
<font face="courier new" size=3><pre>
</pre></font><a href="http://webtime-project.net"><img border=0 src="webtimelogo.jpg"></a>
<font face="courier new" size=3><pre>
site/testimonials.html view on Meta::CPAN
it constraintless to use because of <a href=cgi.html><font size=-1 face=verdana><b>CGI</b></font></a>'s universality and perl's
portability.
<font face="courier new" size=3><pre>
-- Grégoire Lejeune
</pre></font>
<p>
<a name=David%20Kulp></a>
<font face=verdana><font class=title size=+0 color=#555555><b>David Kulp</b></font>
<font face="courier new" size=3><pre>
</pre></font>First, I just want to say that I am very very impressed with Apache::ASP. I
just want to gush with praise after looking at many other implementations of
perl embedded code and being very underwhelmed. This is so damn slick and
clean. Kudos! ...
<font face="courier new" size=3><pre>
</pre></font>... I'm very pleased how quickly I've been able to mock
up the application. I've been writing Perl <a href=cgi.html><font size=-1 face=verdana><b>CGI</b></font></a> off and on since 1993(!)
and I can tell you that Apache::ASP is a pleasure. (Last year I tried
Zope and just about threw my computer out the window.)
<font face="courier new" size=3><pre>
-- David Kulp
site/xml.html view on Meta::CPAN
<font face="courier new" size=3><pre>
</pre></font>Before XML, there was the need to make HTML markup smarter.
Apache::ASP gives you the ability to have a perl
subroutine handle the execution of any predefined tag,
taking the tag descriptors, and the text contained between,
as arguments of the subroutine. This custom tag
technology can be used to extend a web developer's abilities
to add dynamic pieces without having to visibly use
<% %> style code entries.
<font face="courier new" size=3><pre>
</pre></font>So, lets say that you have a table that
you want to insert for an employee with contact
info and the like, you could set up a tag like:
<font face="courier new" size=3><pre>
<my:new-employee name="Jane" last="Doe" phone="555-2222">
Jane Doe has been here since 1998.
</my:new-employee>
</pre></font>To render it with a custom tag, you would tell
the Apache::ASP parser to render the tag with a
subroutine:
<font face="courier new" size=3><pre>
( run in 2.339 seconds using v1.01-cache-2.11-cpan-d7a12ab2c7f )