Re: missing curly - brain fried
- From: martin@xxxxxxxxxx (Martin Barth)
- Date: Thu, 28 Jun 2007 17:20:58 +0200
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: //, /* and */ are not allowed in perl.
there are some other mistakes in your code (e.g use "for" always in this
way: for(..) { .. } ) but you should fix your comments first and then you
can start over trying to learn perl :)
Have fun!
HTH, Martin
On Thu, 28 Jun 2007 17:54:01 +0300
"Amichai Teumim" <amichai@xxxxxxxxxx> wrote:
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] = $array[$j+1];
$array[$j+1] = $tmp;
}
}
foreach $elem (@array){
print "$elem";
}
- References:
- missing curly - brain fried
- From: Amichai Teumim
- missing curly - brain fried
- Prev by Date: Re: String Manipulation
- Next by Date: Re: missing curly - brain fried
- Previous by thread: missing curly - brain fried
- Next by thread: Re: missing curly - brain fried
- Index(es):
Relevant Pages
|