If you have not already got the solution try this.  I am sure the gurus out
there can clean up the code to make it short.

# --- testing the fuction  --
# --- $i simulating the row number or cell number as you wish --

for ($i=0; $i<10; $i++){

 print &get_cell_color($i);

}


# --- function to set color ---
sub get_cell_color {

    my $cell_no = shift;

    my $red_color =  qq{#ff0000};
    my $blue_color =  qq{#00ff00};

    my $prime =  $cell_no % 2;    #  checking for prime.

    my $cell_color = (($prime)? $red_color : $blue_color );

    return $cell_color;

}

Regards

Rajeev

________________________________________________

"Everyone you meet deserves to be greeted with a smile."



----- Original Message -----
From: "Sudarsan Raghavan" <[EMAIL PROTECTED]>
To: "Zachary Buckholz" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, June 05, 2002 5:01 PM
Subject: Re: probably a simple question


> Zachary Buckholz wrote:
>
> > Is there any function to tell if a number is even or odd?
> > I am looking for an easy way to loop through a list and
> > output table cell bgcolor based on even / odd.
> >
> > if its an even numbered row make it red if its odd make
> > it blue.
>
> $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list);
>
> >
> >
> > I have done it in the past by turning a switch on or off
> > but I think there must be an easier way.
> >
> > zack
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
----- Original Message -----
From: "Sudarsan Raghavan" <[EMAIL PROTECTED]>
To: "Zachary Buckholz" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, June 05, 2002 5:01 PM
Subject: Re: probably a simple question


> Zachary Buckholz wrote:
>
> > Is there any function to tell if a number is even or odd?
> > I am looking for an easy way to loop through a list and
> > output table cell bgcolor based on even / odd.
> >
> > if its an even numbered row make it red if its odd make
> > it blue.
>
> $_ % 2 ? print "blue\n" : print "red\n" foreach (@your_list);
>
> >
> >
> > I have done it in the past by turning a switch on or off
> > but I think there must be an easier way.
> >
> > zack
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to