Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 1st, 2000, 11:10 AM
SpuTTer SpuTTer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: California, USA
Posts: 9 SpuTTer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old November 1st, 2000, 01:20 PM
yuccatan yuccatan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Boston, MA
Posts: 6 yuccatan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 8 sec
Reputation Power: 0
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).]

Reply With Quote
  #3  
Old November 1st, 2000, 09:34 PM
SpuTTer SpuTTer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Location: California, USA
Posts: 9 SpuTTer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Great! I didn't consider using MOD.

Thanks a ton

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Even & Odd function in PERL?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway