ASP
view release on metacpan or search on metacpan
unless (wantarray) {
if ($main::Request->ServerVariables('REQUEST_METHOD')->Item eq 'GET') {
return $main::Request->QueryString($_[0])->Item($_[1]);
} else {
return $main::Request->Form($_[0])->Item($_[1]);
}
} else {
my ($i, @ret);
if ($main::Request->ServerVariables('REQUEST_METHOD')->Item eq 'GET') {
my $count = $main::Request->QueryString($_[0])->{Count};
for ($i = 1; $i <= $count; $i++ ) {
push @ret, $main::Request->QueryString($_[0])->Item($i);
}
} else {
my $count = $main::Request->Form($_[0])->{Count};
for ($i = 1; $i <= $count; $i++) {
push @ret, $main::Request->Form($_[0])->Item($i);
}
}
return @ret;
}
}
=head2 param_count EXPR
Returns the number of times EXPR appears in the request (Form or
QueryString).
For example, if URL is
myscript.asp?x=a&x=b&y=c
then
param_count('x');
returns 2.
NOTE: Under Apache::ASP, param_count() performs some manipulation
using CGI::param() because Apache::ASP doesn't support the
$obj->{Count} property used in this function.
=cut
sub param_count {
if ($APACHE) {
return scalar( @{[ CGI::param($_[0]) ]} );
}
if ($main::Request->ServerVariables('REQUEST_METHOD')->Item eq 'GET') {
return $main::Request->QueryString($_[0])->{Count};
} else {
return $main::Request->Form($_[0])->{Count};
}
}
=head2 AddDeathHook LIST
Allows cleanup code to be executed when you C<die> or C<exit>.
Useful for closing database connections in the event of a
fatal error.
<%
my $conn = Win32::OLE-new('ADODB.Connection');
$conn->Open("MyDSN");
$conn->BeginTrans();
ASP::AddDeathHook( sub { $Conn->Close if $Conn; } );
%>
Death hooks are not executed except by explicitly calling the die() or exit()
methods provided by ASP.pm.
AddDeathHook is not exported.
=cut
sub AddDeathHook { push @DeathHooks, @_; }
# These two functions are ripped from CGI.pm
sub expire_calc {
my($time) = @_;
my(%mult) = ('s'=>1,
'm'=>60,
'h'=>60*60,
'd'=>60*60*24,
'M'=>60*60*24*30,
'y'=>60*60*24*365);
# format for time can be in any of the forms...
# "now" -- expire immediately
# "+180s" -- in 180 seconds
# "+2m" -- in 2 minutes
# "+12h" -- in 12 hours
# "+1d" -- in 1 day
# "+3M" -- in 3 months
# "+2y" -- in 2 years
# "-3m" -- 3 minutes ago(!)
# If you don't supply one of these forms, we assume you are
# specifying the date yourself
my $offset;
if ( !$time || $time eq 'now' ) {
$offset = 0;
} elsif ( $time =~ /^([+-]?\d+)([mhdMy]?)/ ) {
$offset = ($mult{$2} || 1)*$1;
} else {
return $time;
}
return ($time + $offset);
}
=head1 AUTHOR
Tim Hammerquist E<lt>F<tim@dichosoft.com>E<gt>
=head1 HISTORY
=over 4
=item Version 1.07
Added Warn() because warn() overloading doesn't appear to work
under Apache::ASP.
( run in 1.770 second using v1.01-cache-2.11-cpan-39bf76dae61 )