Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How would I write code to return the number 4 given x=28? Or alternatively if x=16 then I would return 2. I also need to return the higher number if x falls in between two numbers. The only way solution I can think of is to use if statements, but I will have about a dozen numbers in the hash and writing if statements would take a while.$num{'15'}=1; $num{'20'}=2; $num{'25'}=3; $num{'30'}=4; $x=28;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List of Numbers
by Abigail-II (Bishop) on Jan 18, 2003 at 20:53 UTC | |
|
Re: List of Numbers
by gjb (Vicar) on Jan 18, 2003 at 20:29 UTC | |
by Anonymous Monk on Jan 18, 2003 at 20:36 UTC | |
|
Re: List of Numbers
by BrowserUk (Patriarch) on Jan 18, 2003 at 20:50 UTC | |
|
Re: List of Numbers
by fruiture (Curate) on Jan 18, 2003 at 20:39 UTC | |
|
Re: List of Numbers
by graff (Chancellor) on Jan 20, 2003 at 05:27 UTC | |
|
Re: List of Numbers
by OM_Zen (Scribe) on Jan 18, 2003 at 21:20 UTC | |
by Aristotle (Chancellor) on Jan 18, 2003 at 21:56 UTC |