Lol!  I ripped that right out of Apache::Status.  Any ideas as to
whether or not its faster with map or push?  I may, desire dependent,
benchmark the two formats and report the results.
        It looks to me like the reason Doug did the code the way he did
was because he returns an array ref to the calling sub.  --SC


        PS  CGI.pm does not reside on my system because of it's HTML
generation capabilities (and the consiquent memory bloat).  ;)

On 14 Feb 2000, Randal L. Schwartz wrote:

> Date: 14 Feb 2000 09:35:06 -0800
> From: Randal L. Schwartz <[EMAIL PROTECTED]>
> To: Sean Chittenden <[EMAIL PROTECTED]>
> Cc: Brendan W. McAdams <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Subject: Re: PerlChildInitHandler
> 
> >>>>> "Sean" == Sean Chittenden <[EMAIL PROTECTED]> writes:
> 
> Sean>         Check to make sure that you compiled in the Init and Exit handlers
> Sean> into mod_perl.
> 
> Sean>         If you include the following code in a script, you should be able
> Sean> to figure this out really quick:
> 
> Sean>     require mod_perl;
> Sean>     require mod_perl_hooks;
> Sean>     my @retval = qw(<table>);
> Sean>     my @list = mod_perl::hooks();
> Sean>     for my $hook (sort @list) {
> Sean>         my $on_off = 
> Sean>           mod_perl::hook($hook) ? "<b>Enabled</b>" : "<i>Disabled</i>";
> Sean>         push @retval, "<tr><td>$hook</td><td>$on_off</td></tr>\n";
> Sean>     }
> Sean>     push @retval, qw(</table>);
> 
> Sean>     print @retval;
> 
> Ewww... Too many pushes. :)
> 
>     require mod_perl;
>     require mod_perl_hooks;
>     print "<table>",
>       (map {
>         "<tr><td>", $_, "</td><td>",
>         (mod_perl::hook($_) ? "<b>Enabled</b>" : "<i>Disabled</i>"),
>         "</td></tr>\n" } mod_perl::hooks()),
>       "</table>";
> 
> map is your friend.  Of course, this would have been even simpler with
> CGI.pm HTML generators. :)
> 
> 

-- 
Sean Chittenden
[EMAIL PROTECTED]
(408)530-0001

Reply via email to