<?xml version="1.0" encoding="windows-1252"?>
<node id="1007802" title="Re^2: new keyword &quot;size&quot; to avoid scalar trap ? ( scalar @array != scalar(LIST) )" created="2012-12-07 12:28:38" updated="2012-12-07 12:28:38">
<type id="11">
note</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
I care less about the name than the functionality, could be also "count" or whatever suits. &lt;P&gt;

I suppose "elems" is already known from ruby or perl6? So why not.¹&lt;P&gt;

But² [tobyink]s and [Moritz|your] suggestion w/o prototypes is considerably slower on large arrays.&lt;P&gt;

&lt;c&gt;
  DB&lt;106&gt; use Time::HiRes qw(time)
 
  DB&lt;107&gt; sub elems { scalar @_ }
 
  DB&lt;108&gt; @a=(1..1e6);0
 
  DB&lt;109&gt; $t=time; $count = scalar @a; print time-$t
7.10487365722656e-05
  DB&lt;110&gt; $t=time; $count = elems @a; print time-$t
0.0554749965667725
&lt;/c&gt;&lt;P&gt;

Perl 5.10!
&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;&lt;P&gt;

¹) Well the plural in "elems" somehow indicates a list to be returned.  &lt;P&gt;

²) [id://1007795|as already said]</field>
<field name="root_node">
1007787</field>
<field name="parent_node">
1007798</field>
</data>
</node>
