sub rand3 { my $foo = shift; my $bar = ''; while (length $foo) { $bar .= substr($foo, rand(length $foo), 1, ''); } return $bar; }