<?xml version="1.0" encoding="windows-1252"?>
<node id="1004379" title="Re: elsif statement not being evaluated" created="2012-11-18 01:27:50" updated="2012-11-18 01:27:50">
<type id="11">
note</type>
<author id="918402">
2teez</author>
<data>
<field name="doctext">
&lt;p&gt;
Hi [jonagondos],&lt;br&gt;
 check this in your code:
  &lt;c&gt;
if ( $choice = $an2 ) {
 ...
}
elsif ( $choice = $an1 ) {
 ...
}
&lt;/c&gt; I suppose you want to use 
&lt;c&gt;
if ( $choice == $an2 ) {
 ...
}
elsif ( $choice == $an1 ) {
 ...
}
&lt;/c&gt;
  You are &lt;tt&gt;assigning&lt;/tt&gt; to variable $choice, the value of the variable $ans2 using the &lt;a href="http://perldoc.perl.org/perlop.html#Assignment-Operators"&gt;assignment&lt;/a&gt; operator &lt;tt&gt; '=' &lt;/tt&gt;. &lt;br&gt;
So, whatsoever, value inputted was replaced by the value of variable $ans2.&lt;br&gt;
In which case variable $choice value is &lt;b&gt;ALWAYS&lt;/b&gt; evaluate to &lt;tt&gt;2&lt;/tt&gt; the pre-defined value of variable $ans2, so your &lt;tt&gt;elsif(){...}&lt;/tt&gt; statement is not being evaluated.
&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-918402"&gt;
If you tell me, I'll forget.&lt;br&gt;
If you show me, I'll remember.&lt;br&gt;
if you involve me, I'll understand.&lt;br&gt;
--- Author [unknown to me]
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1004376</field>
<field name="parent_node">
1004376</field>
</data>
</node>
