<?xml version="1.0" encoding="windows-1252"?>
<node id="1010793" title="Re: Palindrome array" created="2012-12-29 01:13:00" updated="2012-12-29 01:13:00">
<type id="11">
note</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
The ugly truth is both don't work!&lt;P&gt;

[doc://eq] forces scalar context and is meant to compare &lt;u&gt;strings&lt;/u&gt;&lt;P&gt;

So in the first code you are checking if the sizes (after stringification) are equal.&lt;P&gt;

&lt;c&gt;
  DB&lt;107&gt; @a = 1..3
 =&gt; (1, 2, 3)
 
  DB&lt;108&gt; @a eq "3"
 =&gt; 1
&lt;/c&gt;&lt;P&gt;

in the second you have scalar from reverse on RHS&lt;P&gt;

&lt;c&gt;
  DB&lt;123&gt; (reverse @a)
 =&gt; (3, 2, 1)
 
  DB&lt;124&gt; scalar (reverse @a)
 =&gt; 321
 
  DB&lt;125&gt; "321" eq (reverse @a)
 =&gt; 1
&lt;/c&gt;&lt;P&gt;

please stop doing weird things!&lt;P&gt;

you can try the (less weird) smart match operator ~~ to compare arrays.
 
&lt;c&gt;
  DB&lt;129&gt; @a=(3,1,3)
 =&gt; (3, 1, 3)
 
  DB&lt;130&gt; @a ~~ [reverse @a]
 =&gt; 1
 
  DB&lt;131&gt; @a ~~ [3,1,3]
 =&gt; 1
 
  DB&lt;132&gt; @a=1..3
 =&gt; (1, 2, 3)
 
  DB&lt;133&gt; @a ~~ [reverse @a]
 =&gt; ""
&lt;/c&gt;&lt;P&gt;

a poor man's solution with eq is to explicitly stringify on both sides.&lt;P&gt;

&lt;c&gt;
  DB&lt;143&gt; @a=(3,1,3)
 =&gt; (3, 1, 3)
 
  DB&lt;144&gt; @ar=reverse @a
 =&gt; (3, 1, 3)
 
  DB&lt;145&gt; "@a"
 =&gt; "3 1 3"
 
  DB&lt;146&gt; "@a" eq "@ar"
 =&gt; 1
&lt;/c&gt;&lt;P&gt;

But this depends on the nature of your array elements, don't be too surprised about:&lt;P&gt;

&lt;c&gt;
  DB&lt;151&gt; "@a"
 =&gt; "3 1 3"
 
  DB&lt;152&gt; @b=(3,"1 3")
 =&gt; (3, "1 3")
 
  DB&lt;153&gt; "@a" eq "@b"
 =&gt; 1
&lt;/c&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1010790</field>
<field name="parent_node">
1010790</field>
</data>
</node>
