Ken,
no - mod_perl as glue to the Apache API is required. If you're not running
under mod_perl these won't work for you and you have to use CGI.pm's or
URI's perl only functions.
At 12:19 PM 11/1/99 -0500, Ken Y. Clark wrote:
>On Mon, 1 Nov 1999, John Siracusa wrote:
>
>> Can I use the Apache::Util functions outside mod_perl? Here's an attempt:
>>
>> % cat > test.pl
>> use Apache::Util;
>>
>> print Apache::Util::escape_html('<foo>');
>> % perl test.pl
>> Undefined subroutine &Apache::Util::escape_html called at test.pl line 3.
>>
>> I'd like to have access to the fast URL/HTML escaping subroutines
>> in "regular" perl scripts, if possible.
>>
>> -John
>
>isn't that functionality available in CGI?
Yes it is, however much slower than the native ones in Apache (from
Apache::Util):
use Benchmark;
timethese(1000, {
C => sub { my $esc = Apache::Util::escape_html($html) },
Perl => sub { my $esc = HTML::Entities::encode($html) },
});
Benchmark: timing 1000 iterations of C, Perl...
C: 0 secs ( 0.17 usr 0.00 sys = 0.17 cpu)
Perl: 15 secs (15.06 usr 0.04 sys = 15.10 cpu)
use Benchmark;
timethese(10000, {
C => sub { my $esc = Apache::Util::escape_uri($uri) },
Perl => sub { my $esc = URI::Escape::uri_escape($uri) },
});
Benchmark: timing 10000 iterations of C, Perl...
C: 0 secs ( 0.55 usr 0.01 sys = 0.56 cpu)
Perl: 2 secs ( 1.78 usr 0.01 sys = 1.79 cpu)
Tobias