On Friday 09 November 2007 04:55, John W.Krahn wrote:
>
> On Thursday 08 November 2007 17:11, Inventor wrote:
> >
> > if ($i == 0) {
> > if (@s1[0] eq "QBCnlq57Byh") {
>
> If you had warnings enabled perl would have warned you about using an
> array slice where you should be using a scalar.
>
> > $approved = 1;
> > } else {
> > $approved = 0;
> > }
> > } else {
> > if (($approved == 1) & (@s1[0] eq "nhnbyh")) {
Another thing I noticed is that you are using a bitwise and operator
(&) when you should really be using a logical and operator (&&). It is
not that the bitwise operator won't do what you want, it is because the
logical operators short-circuit.
perldoc perlop
[snip]
C-style Logical And
Binary "&&" performs a short-circuit logical AND opera
tion. That is, if the left operand is false, the right
operand is not even evaluated. Scalar or list context
propagates down to the right operand if it is evaluated.
C-style Logical Or
Binary "||" performs a short-circuit logical OR operation.
That is, if the left operand is true, the right operand is
not even evaluated. Scalar or list context propagates
down to the right operand if it is evaluated.
Whereas the bitwise operators would have to evaluate every expression
irregardless of whether they were true or false.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/