Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: switch statement

by BillKSmith (Monsignor)
on Oct 01, 2015 at 16:52 UTC ( [id://1143589]=note: print w/replies, xml ) Need Help??


in reply to switch statement

In the case (no pun) that your intention is compute a single value, you can use the ternary operator:
use strict; use warnings; my $score = 77; my $grade = $score >= 90 ? 'A' : $score >= 80 ? 'B' : $score >= 70 ? 'C' : $score >= 60 ? 'D' : 'F' ; print "$grade\n";
Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-19 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found