Date sent: Thu, 10 Jul 2003 14:03:32 -0700 (PDT) From: Hari Krishnaan <[EMAIL PROTECTED]> Subject: Question on For loop usage in Perl To: [EMAIL PROTECTED]
> Hello all, > I was using a for loop in the following manner in one of my perl > programs. > > for($j=31, $n=$initial;$j>=0,$n<=$final;$j--,$n++) { > > # Executing statements here > } > > 1) Is it legal in perl to use the for loop as mentioned above ? Well ... it compiles. > 2) If so when i compile perl gives a message as follows > : > "Useless use of integer ge (>=) in void context" > > What does this message mean ? Is this an error message or a warning > message ? it's a warning. But a warning you should care about. It says that you test whether $j is greater or equal to zero ... but you do not use the result of that test in any way. Your code is exactly equivalent to: for($j=31, $n=$initial;$n<=$final;$j--,$n++) { In this case I believe you wanted this: for($j=31, $n=$initial;$j>=0 and $n<=$final;$j--,$n++) { HTH, Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]