>
>Hi Jeff Ji, your program worked. But i couldn't understand the second
>line.. That long print statement. What happened there? My 'simple'
>sort arranged numbers in dictionary style.. Like 0 then 1 then 17 then
>2 and then 29.. And how come in using strict module, that $a and $b
>didnt make any noise? When i did it on command line, it said
>
As I've said,would you show us the pieces of your array?
print join "\n",@sorted_arr;
For this statement,at first I join the @sorted_arr to a string with symbol
"\n",then I print this string.
$a and $b is Perl's inherent variables,both them are used for Perl's sort
function (see perldoc -f sort),you don't need to declare them even in strict
mode.
What's "dictionary style"?Do you mean something like Python's dict stru?
For a simple numeric array,we can use 'sort' to re-order them exactly.
use strict;
use warnings;
use Data::Dumper;
my @arr = qw(3 0 4 1 2 5);
my @new = sort { $a <=> $b } @arr;
print Dumper [EMAIL PROTECTED];
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/