The process you describe is a shuffle. If you don't want to use List::Util which AFAIK is not core (for <5.8 ) then you could just use a Fisher Yates shuffle like this:
sub random { my @array = split //, shift; for (my $i = @array; --$i; ) { my $j = int rand ($i+1); @array[$i,$j] = @array[$j,$i]; } return join '', @array; } print random('hello');
UpdateAristotle notes that List::Util is core from 5.8.
cheers
tachyon
In reply to Re: Randomize word
by tachyon
in thread Randomize word
by vikee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |