Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Randomize elements among several arrays, while maintaining original array sizes.

by Roy Johnson (Monsignor)
on Aug 01, 2008 at 19:07 UTC ( [id://701760]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        for( 0 .. $#$ref ) {
            my $p = $_ + rand( $n-- );
            @{$ref}[$p,$_] = @{$ref}[$_,$p];
        }
    
  2. or download this
    sub my_shuffle2 {
        my $ref = \@_;
    ...
        return unless defined wantarray;
        return wantarray ? @{ $ref } : $ref;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://701760]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found