modperl_map_mysteries

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: bari <bari@sonicbox.com>
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Help needed with MAP expression
Date: Fri, 8 Dec 2000 10:13:37 +0000 (GMT)

On Thu, 7 Dec 2000, bari wrote:

> Hi there,
> Can any one help me what this MAP function does...
>
>  map(/^[\.\d]+$/ ? td({-align=>'right'}, $_) : td($_), @$_)

$_ contains an array ref. It loops through each entry in the array ref. If
the entry is a number (by the above regexp's naive view of numbers), it
maps it to <td align="right">number</td>, otherwise it maps it to
<td>value</td>.

The use of $_ as the container for the array ref, while using map (which
gives you a $_ inside the map expression) is scary scary obfuscated
nastiness and deserves a slap for whoever wrote it.

===

To: bari <bari@sonicbox.com>
From: jbodnar@gocho.net
Subject: RE: Help needed with MAP expression
Date: Thu, 07 Dec 2000 18:01:04 -0600 (CST)

It takes a reference to an array, and checks to see if each element of the
arry only contains one or more "."s or digits, if it does it calls the td()
function with parameters, returning the result, if not, it returns the element.

I think.

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu