On Fri, 22 Nov 2002 03:28:39 -0800, [EMAIL PROTECTED] (Poster) wrote: >Hi, I am having a little trouble with a sub that is using the modulus >operator.
Yeah, it fooled me too for a bit :-) The problem is the way you pass the value to the sub, @_ always is 1, the count of elements in @_. Change @_ to @_[0] or better yet $_[0] > >It is called here-within a while loop: >while (my $row = $sth->fetchrow_hashref()) { > count++; > color_rows( $count ) > ------some other stuff > <td bgcolor="$bgcolor">table cell value</td> > -----some other stuff >} >--here is the sub >sub color_rows >{ >my $num = @_; my $num = $_[0]; >my $bgcolor; > >If ( $num % 2 == 0 ) { > $bgcolor="#bde6de"; >} else { > $bgcolor="white"; >} >return $bgcolor; >}#end sub > >I expect that when the value that is passed in $count is even it will >set the row color green, otherwise it will set it to white. What it is >actually doing is setting the value white every time. > >Thanks. > >Ramon Hildreth >------------------------------------------------------------------- >[ www.subudusa.org ] [ www.subudseattle.org ] > [ www.ramonred.com ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]