<br><br><div class="gmail_quote">On Wed, Dec 3, 2008 at 6:50 PM, Jay Hannah <span dir="ltr">&lt;<a href="mailto:jay@jays.net">jay@jays.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
From: <a href="mailto:brandonglesmann@gmail.com" target="_blank">brandonglesmann@gmail.com</a><br>
Date: December 3, 2008 4:42:30 PM CST<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Disclaimer: I have been out of perl programming for over two years. So, I am really rusty. Also I never used the perl debugger so I could be misinterpreting the output. Lastly, I am a coward which is why I did not reply all.<br>

</blockquote>
<br>
Well, thanks for saying it was OK for me to drag you into the sunshine so all can benefit from my stupidity. &nbsp;:)<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
WOW! Ok, I read that 10 times and have asked other perl programmers in the area to read it as well.<br>
</blockquote>
<br>
Other Perl programmers? Sweet! Are they on the Omaha Perl Mongers mailing list? Recruit them! &nbsp;:)<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
couple questions:<br>
1. How are the cases different? If &#39; &#39; is true and then both cases of your example should be the same.......right?!?! Obviously not since you changed the code but I don&#39;t know why.<br>
</blockquote>
<br>
&#39; &#39; is very different from &#39;&#39;. &nbsp; :)<br>
<br>
I&#39;m often a hunt and peck coder, so whatever perl does is the right answer. I don&#39;t know that there necessarily is a &quot;why&quot;. (Other than &quot;because that&#39;s what perl&#39;s C source code says&quot; -grin-). So let&#39;s try some things...<br>

<br>
First, note that &#39;&#39; is false and &#39; &#39; is true.<br>
<br>
$ cat j.pl<br>
print &#39;&#39; &nbsp;? &#39;yes &#39; : &#39;no &#39;;<br>
print &#39; &#39; ? &#39;yes &#39; : &#39;no &#39;;<br>
$ perl j.pl<br>
no yes<br>
<br>
But my thing was more like this:<br>
<br>
$ cat j.pl<br>
print ((not defined $j || 1) ? &#39;yes &#39; : &#39;no &#39;);<br>
print ((not defined $j or 1) ? &#39;yes &#39; : &#39;no &#39;);<br>
$ perl j.pl<br>
no yes<br>
<br>
-think,think,think-<br>
<br>
I&#39;m betting this happens due to operator precedence. Reading &quot;perldoc perlop&quot; doesn&#39;t help me much at a glance since I&#39;m not sure where &#39;defined&#39; falls in the documented precedence order stack. But let&#39;s assume for a second that the precedence of &#39;defined&#39; is higher than that of &#39;or&#39; but lower than that of &#39;||&#39;. If that&#39;s true, then:<br>

<br>
 &nbsp; not defined $j || 1<br>
<br>
would be processed as:<br>
<br>
 &nbsp; $j || 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;true<br>
 &nbsp; defined true &nbsp; &nbsp; true<br>
 &nbsp; not true &nbsp; &nbsp; &nbsp; &nbsp; false<br>
<br>
So if &#39;defined&#39; is a &quot;nonassoc list operators (rightward)&quot; then this is probably the correct answer and I feel all smart and stuff. &nbsp; :)<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2. How do you get a eq to return &#39; &#39; ?<br>
</blockquote>
<br>
You don&#39;t? Apparently it returns &#39;&#39; if false, 1 if true:<br>
<br>
$ perl -d -e 1<br>
 &nbsp;DB&lt;1&gt; x $j eq &#39;blah&#39;<br>
0 &nbsp;&#39;&#39;<br>
 &nbsp;DB&lt;2&gt; x $j eq &#39;&#39;<br>
0 &nbsp;1<br>
<br>
perldoc perlop says:<br>
<br>
 &nbsp;Binary &quot;eq&quot; returns true if the left argument is stringwise equal to<br>
 &nbsp;the right argument.<br>
<br>
And &#39;&#39; is false, and &#39;1&#39; is true, so there you have it... &nbsp;:)<br>
<br>
Did that help at all?<br></blockquote></div><br>Just a thought...<br><br>C&lt;||&gt; is higher then C&lt;not&gt;&nbsp; but<br>C&lt;!&gt; is higher then C&lt;||&gt; :P<br><br>If you put parentheses in the right place you get what you want.<br>

<br>
cat t.pl<br>print (((not defined $j) || 1) ? &#39;yes &#39; : &#39;no &#39;);<br>print (((not defined $j) or 1) ? &#39;yes &#39; : &#39;no &#39;);<br>
print ((! defined $j || 1) ? &#39;yes &#39; : &#39;no &#39;);<br>
print ((not defined $j or 1) ? &#39;yes &#39; : &#39;no &#39;)<br>yes yes yes yes<br><br><br>-- <br>Ted Katseres<br> &nbsp; &nbsp; &nbsp;||=O=||<br>