<?xml version="1.0" encoding="windows-1252"?>
<node id="866292" title="Re: Confused as to why the &quot;casting context&quot; is mis-behaving" created="2010-10-20 07:47:37" updated="2010-10-20 07:47:37">
<type id="11">
note</type>
<author id="664508">
philipbailey</author>
<data>
<field name="doctext">
&lt;p&gt;This is one of those times when there is a difference between a list and an array in Perl.  It seems hard to produce a concise definition of the difference, but to a first approximation an array is a list with a name (such as @a in your examples).  So qw(a b c d e) is a list which you have assigned to @a.&lt;/p&gt;

&lt;p&gt;What you have exposed is that in scalar context, a array and list (both containing the same data) have different values.  The value, in scalar context, of an array, is the number of elements.  The value, in scalar context, of a list, is the last item in that list.&lt;/p&gt;

Update. See &lt;a href="http://perldoc.perl.org/perlfaq4.html#What-is-the-difference-between-a-list-and-an-array?"&gt;perlfaq4&lt;/a&gt;</field>
<field name="root_node">
866291</field>
<field name="parent_node">
866291</field>
</data>
</node>
