CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Syntax error in short sub routine

 



squallsquall
Novice

Nov 27, 2008, 6:36 AM

Post #1 of 3 (281 views)
Syntax error in short sub routine Can't Post

Hi,

I've used other languages before, but am new to Perl. I've written my first sub routine but keep getting syntax errors. What might be wrong?

Thanks!


Code
sub lower_odds 
{
my ($odds)=@_;
if ($odds < 2.02) {
$odds -= 0.01;
} else if ($odds < 3.05) {
$odds -= 0.02;
} else if ($odds < 4.1) {
$odds -= 0.05;
} else if ($odds < 6.2) {
$odds -= 0.1;
} else {
$odds -= 0,2;
}

return $odds;
}



FishMonger
Veteran / Moderator

Nov 27, 2008, 6:47 AM

Post #2 of 3 (279 views)
Re: [squallsquall] Syntax error in short sub routine [In reply to] Can't Post


Code
} else if


should be:

Code
} elsif



squallsquall
Novice

Nov 27, 2008, 7:15 AM

Post #3 of 3 (276 views)
Re: [FishMonger] Syntax error in short sub routine [In reply to] Can't Post

No way :)

I'm glad I posted here, would never have figured that out myself... far too used to other languages.

Thanks a lot!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives