<?xml version="1.0" encoding="windows-1252"?>
<node id="1005595" title="Re: Trouble getting size of list returned from sub" created="2012-11-26 04:01:37" updated="2012-11-26 04:01:37">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;"Is there no way to avoid the temp variable?"&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Kinda. It comes down to the difference between lists and arrays. Assigning an array to a scalar gives you the length of the array. Assigning a list to a scalar gives you the final item in the list.&lt;/p&gt;

&lt;p&gt;That said, Perl allows arrays to be anonymous. So even if you need an array, you don't need to create a variable for it...&lt;/p&gt;

&lt;c&gt;
say scalar @{[ bad() ]};
&lt;/c&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005594</field>
<field name="parent_node">
1005594</field>
</data>
</node>
