[LA.pm] alternating...

Jeff Yoak jeff at yoak.com
Sat Jun 25 20:22:52 PDT 2005


At 01:08 PM 6/25/2005, William Reardon wrote:

>Here's an easier way to do the same thing, using the modulo operator:
>
>my @mem = qw|foo bar baz bang bong bing ding dong dang|;
>
>my $n = 0;
>foreach my $line (@mem) {
>    print '<TR><TD BGCOLOR="',
>      $n++ % 2 ? '#93c0c0' : '#cae8ff',
>        "<A HREF='$line'>$line</A></TD></TR>\n\n";
>}

And even easier without it:

my @mem = qw|foo bar baz bang bong bing ding dong dang|;

foreach my $line (@mem) {
    print '<TR><TD BGCOLOR="',
      $|-- ? '#93c0c0' : '#cae8ff',
        "<A HREF='$line'>$line</A></TD></TR>\n\n";
}

Oh, wait.  This isn't the fwp mailing list.  Never mind.  ;-)

Cheers,
Jeff




More information about the Losangeles-pm mailing list