<?xml version="1.0" encoding="windows-1252"?>
<node id="626191" title="Re^4: About List::Util's pure Perl shuffle()" created="2007-07-12 06:36:17" updated="2007-07-12 02:36:17">
<type id="11">
note</type>
<author id="409850">
blazar</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;&lt;c&gt;
sub bukNew ($) {
    my( $ref ) = @_;
    my @x = 0 .. $#$ref;
    @{ $ref }[ map splice( @x, rand @x, 1 ), @x ];
}
&lt;/c&gt;&lt;/i&gt;&lt;/blockquote&gt;

&lt;p&gt;More and more interesting. But then, since &lt;em&gt;all&lt;/em&gt; the other subs are &lt;c&gt;(@)&lt;/c&gt;, why not simply the following?&lt;/p&gt;

&lt;c&gt;
sub bukNew (@) {
    my @x = 0 .. $#_;
    @_[ map splice( @x, rand @x, 1 ), @x ];
}
&lt;/c&gt;

&lt;p&gt;However some random tests with various string and list lengths seem to show that it could be considerably slower than &lt;c&gt;buk()&lt;/c&gt;, by even as much as 40% or so. Thus... are you sure your benchmark is not flawed?&lt;/p&gt;</field>
<field name="root_node">
625977</field>
<field name="parent_node">
626155</field>
</data>
</node>
