First of all, welcome to the Monastery!
Second, as Corion already remarked, this smells like homework, and Perl 101 homework at that; and as a general rule the Monastery will not do your homework for you, though it will of course help you if you're stuck. This is primarily because we're a bunch of lazy bastards (hey, it's one of the three cardinal virtues!), but it's also for your own benefit. The only way to learn Perl is to write Perl, and if you give up this early on in your journey, how will you ever get anywhere?
So, let this post encourage you. Don't give up! Learning programming may appear daunting when you're getting your feet wet for the first time, but you can do it. And Perl is a friendly language that works for and with you, not against you, and that tries hard to do the right thing instead of weaseling out on technicalities, as some other languages like to do.
Now, for your particular task, here's some links that may help. Input/output is covered in the I/O Operators section of perlop. For performing a task a certain number of times, refer to Compound Statements in perlsyn. perldata has more on lists. Perl's documentation is excellent in general, and although it's very exhaustive and covers many details that may not be of interest to you (yet), I highly recommend it. There's gold in them thar hills, as it were.
I also recommend both Beginning Perl and Learning Perl as introductions to Perl, and Programming Perl as a general reference. If you're a student, your school's library may well have copies. (And if not, suggest buying them!)
Finally, not to toot my own horn, but my home node has links to all sorts of material, for new and experienced users alike. It's a work in progress, but you may still find it useful.
All the best, and have fun with Perl!
| [reply] |
Most likely your course material will cover most of the stuff you need. What code have you written and where does your code fail to do what you need?
| [reply] |
Some hints:
- Read the numbers from STDIN
- Chomp
- Push to an array until it has 10 slots
- Sort the array numerical and get the indexes 0 and -1
- Print out the result
If you get stuck, ask again (Solution prepared ;-) )
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] |