On 6/28/07, Amichai Teumim <[EMAIL PROTECTED]> wrote:
Where is the open curly missing here?
Here it is:
@array = sort { $a <=> $b } @array;
But if you really want to do it the hard, slow way Well, then you
should be programming this as a shell script. But let's at least
translate your
> Where is the open curly missing here?
>
> #!/usr/bin/perl
>
> @array = (5,3,2,1,4);
>
>
> for ($i=0; $i<$n-1; $i++) {
I think its missing on the line bellow. I count three brackets bellow.
> ( for ($j=0; $j<$n-1-$i; $j++)
>
>
> if ($array[$j+1] < $array[$j]) { /* compare the two neighbors
> *
Hi Amichai,
first of all never write own code without these two lines:
use strict;
use warnings;
this should allways help a lot. Remember the e-mail from Chas Owens
regarding the "shuffling cards".
making comments in perl goes this way:
# hello, i am a comment.
you made C-style comments: //,
Where is the open curly missing here?
#!/usr/bin/perl
@array = (5,3,2,1,4);
for ($i=0; $i<$n-1; $i++) {
( for ($j=0; $j<$n-1-$i; $j++)
if ($array[$j+1] < $array[$j]) { /* compare the two neighbors
*/
$tmp = $array[$j]; /* swap $array[j] and $array[j+1]
*/
$array[$j] = $a