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:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old October 27th, 2000, 02:01 AM
MikeAparicio MikeAparicio is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 0 MikeAparicio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm trying to design a script that generates NBA standings from inputted scores. In addition to win/loss records, I want to keep track of division and conference records. So I have several arrays that include the teams that fall under each catetgory:

@teams - All teams
@east/@west - By conference
@pacific, @midwest, @central, @atlantic - By division

How can I say "if Team A is in @pacific and Team B is in @pacific and Team A's score is higher than Team B, then add 1 to Team A's division wins and add 1 to Team B's division losses"?

Any help would be greatly appreciated. Thanks!

Mike

Reply With Quote
  #2  
Old October 27th, 2000, 03:45 AM
chrisdice4 chrisdice4 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Cape Town, WP, South Africa
Posts: 39 chrisdice4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hi there

Interesting so I gave it a bash, it should work in theory

There are two ways first using a data base with associative arrays, and then just with arrays

Try making the divisions Associative arrays or hasehes
so that you can pull the value team A out of the array

#these are from the input form

$score = q->param("score");
$score1 = q->param("score1");
$team = q->param("team");
$team1 = q->param("team1");

#an array to associate the team with the score

%teamscore_array($team,$score,$team1,$score1)
$teamscore = @teamscore_array{$score}
$teamscore1 = @teamscore_array{$score1}


#one array for all the teams associated with the divisions
%division('globe troters', divA,'the magic',divA,'lakers',divB,'bears',divC)#etc

#this gets the teams division

$teamdivision = @division{$team}
$teamdivisoin1 = @division($team1}

#this checks if they are in the same division and adds +1 to the winning team in the data base

if ($teamdivision eq $teamdivision1)
{if ($teamscore > $teamscore1)
{#add 1 to $team in division $teamdivision in your database}
else {#add 1 to $team1 $teamdivision in your database}
}

or if you want to stick with arrays, make an associative array with the team names and their current scores

%teamsandscores_array('the magic',10,'jazz',20)#etc

#this gets the winning team
if ($teamscore > $teamscore1)
{$winningteam = $team}
else{$winningteam = $team1}

#this updates the winning teams score

$teamsandscores_array{$winningteam}(+1)

I havent used the array method before but in theory it should work

use the logic for the rest

Good luck


[This message has been edited by chrisdice4 (edited October 27, 2000).]

[This message has been edited by chrisdice4 (edited October 27, 2000).]

Reply With Quote
  #3  
Old October 27th, 2000, 02:53 PM
MikeAparicio MikeAparicio is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 0 MikeAparicio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the tip! I was able to determine conference, division, home, away, overtime, and overall wins and losses. Thanks again!

Mike

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > checking for value in an array


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 2 hosted by Hostway