Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Randomise a string of letters

by Rhose (Priest)
on Jan 15, 2003 at 14:35 UTC ( #227152=note: print w/replies, xml ) Need Help??

in reply to Randomise a string of letters

Using the "Randomizing an Array" example from the Perl Cookbook, I threw together the following code. Does this help?
#!/usr/bin/perl -w use strict; my $gStr='This is my string'; my @gStrArr=split('',$gStr); sub fisher_yates_shuffle { my $array = shift; my $i; for ($i = @$array; --$i;) { my $j = int rand ($i+1); next if $i == $j; @$array[$i,$j] = @$array[$j,$i]; } } fisher_yates_shuffle(\@gStrArr); $gStr=join('',@gStrArr); print $gStr,"\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://227152]
erix considers showing this to choroba , thinks better of it
[choroba]: LanX we used to mock Hare Krishna processions signing "Hare Rama" carrying the margarine conatiners
[choroba]: :-D
[LanX]: What about Czech an Chechen ambessy?
[AnomalousMonk]: LanX: Rama had (has?) a high (much higher than typical asteroid) rate of axial (again, unusual, I think) spin for its artificial gravity.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2017-11-22 17:04 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (327 votes). Check out past polls.