Axel Gerstmair wrote:

> +sub _init_html_all_filter {
> +    # Try using Apache::Util. Actually we have to call escape_html once
> +    # to find out if it is available. An alternative would be to check for
> +    # the MOD_PERL environment variable.
> +    eval {
> +        use Apache::Util;
> +        Apache::Util::escape_html('');
> +    };


this must be:

   require Apache::Util;

use() is always run at compile time. consider:

% perl -ce 'eval { require XXX }'
-e syntax OK

% perl -ce 'eval { use XXX }'
Can't locate XXX.pm in @INC (@INC contains: 
/usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 
/usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 
/usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 
/usr/lib/perl5/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.


> +    return \&Apache::Util::escape_html
> +        unless ($@);
> +
> +    # Apache::Util is not available, so we try using HTML::Entities
> +    eval "use HTML::Entities";
> +    return \&HTML::Entities::encode_entities
> +        unless ($@);


The same here, no need for a string eval:

eval {require HTML::Entities} && return \&HTML::Entities::encode_entities

But the best is to figure out user's environment at compile time:

use constant HAS_HTML_Entities => eval { require HTML::Entities};
use constant HAS_Apache_Util   => eval { require Apache::Util };

and then use these constants in the code.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Reply via email to