in reply to conditional statement
There's no point in speeding up something that you do only once or twice (though there's still good reason to make it nicer to read).
If you do many such lookups, just construct an array with the grades and look it up:
# do this once: my @grades = ( ('F' ) x 40, # 0..39 ('E' ) x 10, # 40..49 ('D' ) x 10, # 50..59 ('C' ) x 5, # 60..64 ('C+') x 5, # 65..69 ... ); # do this many times: my $grade = $grades[$ARGV[0]]; print "The student has gotten a $grade grade for the score of $ARGV[0] +.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Conditional statement
by Jenda (Abbot) on Apr 25, 2012 at 16:18 UTC |