Ok, this should be very basic. For the life of me I can't figure it out. I searched and searched. Maybe you can help?
In one of my programs I found this wrong way
if ($sender_transaction_type !~ /3|21/)
The above code is wrong, is bad, works sometimes. I know this is wrong. Trying to figure out the right way. I wrote the little test script below.
In the below script the multi-compare Option Equals works fine. But the multi-compare Option Not Equal does not work. Why? How to fix?
For example, set $a = 77 and the Option Not Equal does not work.
Thanks for the help!
use strict;
$a = 8; #Try using 7 and see how second loop does not evaluate correct
+ly
## Examples
# $a = 44 evaluates ok for both options
# $a = 33 evaluates ok for both options
# $a = 3 does not evalute correctly on Option Not Equal
# $a = 77 does not evalute correctly on Option Not Equal
# $a = 8 does not evalute correctly on Option Not Equal
## Option Equal
if (($a == 3) || ($a == 77) || ($a == 8))
{
print "$a must be a 3 77 or 8\n";
}
else
{
print "$a is not a 3 77 or 8\n";
}
print "\n";
## Option Not Equal
if (($a != 3) || ($a != 77) || ($a != 8))
{
print "$a is not a 3 77 or 8\n";
}
else
{
print "$a is a 3 77 or 8\n";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|