Why won't this code return when the scalars don't match?
Because you used a "=" instead of an "eq":
You tested wether you could set $a to the value of $aa instead of making a comparison.
See perldoc perlintro and perldoc perlop for more.
Cheers, Sören
| [reply] |
You assign $aa to $a inside the if so they are equal. To compare them use $a eq $aa for strings or
$a == $aa for numbers.
| [reply] [d/l] [select] |
if ($a cmp $aa) ....
= -- assignment
== - numeric comparison
cmp string comparison
----
I Go Back to Sleep, Now.
OGB
| [reply] [d/l] |
That's not what cmp is for. It's the string equvilent of <=> and is meant for use in sorting operations. In this case, it won't work at all as shown, because it returns 0 when the two strings are equal (unless( $a cmp $aa) would work, but there is a better way).
What the OP really wants is eq.
----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.
| [reply] [d/l] [select] |