|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hello, I am writing to see if there is an even or odd function in PERL..
What I'm trying to do is have alternating table backgrounds.... If even($x) { one color } else { 2nd color}; something like that. Any help is appreciated. Thanks! |
|
#2
|
|||
|
|||
|
I've addressed this before by using modulo math:
if ($x % 2) { INSERT ODD STATEMENTS HERE } else { INSERT EVEN STATEMENTS HERE } (This essentially checks to see if there's a remainder when the number is divided by 2; if there is, than it's odd (hence 'true').) Hope this helps! Cheers, Yuccatan [This message has been edited by yuccatan (edited November 06, 2000).] |
|
#3
|
|||
|
|||
|
Great! I didn't consider using MOD.
Thanks a ton ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Even & Odd function in PERL? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|