Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: using if-elsif-else

by monkey_boy (Priest)
on Dec 28, 2006 at 15:46 UTC ( #592067=note: print w/ replies, xml ) Need Help??


in reply to using if-elsif-else

lots of extra brackets there!, also, an "else" cannot have a conditional, so you need another "elsif", use "else" for a catchall at the end, ive fixed up your snippet below:

if ($name =~ /^derrick\b/i) { print $phnums{"derrick"}; } elsif ($name =~ /^juan\b/i) { print $phnums{"juan"}; } elsif ($name =~ /^kevin\b/i) { print $phnums{"kevin"}; } else { print "No such person!\n"; };



This is not a Signature...


Comment on Re: using if-elsif-else
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://592067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-30 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls