Jeff wrote:
This is a true beginner's question, so bear with me. I have an array of
numbers. Is there a function to tell me which is larger (or smaller?)
Sure. Perl's 'sort' function is quite flexible, and supports
numerically sorting lists. `perldoc -f sort` describes what you want, I
believe.
The short answer:
#!/usr/bin/perl
use warnings;
use strict;
my @numbers = ( 5, 3, 7, 9, 22, 13, 6 );
my @ascending = sort { $a <=> $b } @numbers;
my @descending = sort { $b <=> $a } @numbers;
There is also a nice FAQ entry that can be found with `perldoc -q sort`.
Also,
how do I search with perldoc for a function when I don't know the name?
You could look at `perldoc perlfunc` and browse and search the list of
functions using your pager (it's probably worth reading the whole thing).
`perldoc -q keyword` searches the perl FAQ for keywords, which is often
useful.
http://perldoc.perl.org/ has a web based search of the latest stable
documentation.
-- Douglas Hunter
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/